ΠΔΠ-15 (2003) - Phase A Senior High School (tomato1)

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 1M

Author:
Problem type
Allowed languages
C, C++, Java, Pascal, Python

TOMATO PRODUCTION

It is a fact that if ripe tomatoes are placed among unripe tomatoes in a production line, the unripe tomatoes will start ripening faster.

The problem is as follows: there are n tomatoes placed in a line, numbered from 1 to n (4 \le n \le 200). Only m (1 \le m \le n) tomatoes among them are red, meaning they are ripe. The numbers of the positions of the red tomatoes in the line are m_1, m_2, m_3, where 1 \le m_i \le n. Both neighboring tomatoes of a ripe tomato will ripen, i.e., turn red during a day, if they are not already ripe. Note that each tomato in the line has two neighboring tomatoes, except for the first and last ones, which have only one.

Write a program that calculates how many unripe tomatoes will remain in the line after d (1 ≤ d ≤ 30) days.

Note: In the input data, the numbers of ripe tomatoes are given in ascending order.

Example:
Initial day:     α κ α α α α α α α α α α κ α κ α α α α
End of 1st day: κ κ κ α α α α α α α α κ κ κ κ κ α α α
End of 2nd day: κ κ κ κ α α α α α α κ κ κ κ κ κ κ α α
And so on, where α = unripe tomato and κ = red (ripe) tomato
Input

An input file named INPUT.TXT is given, consisting of 2 lines. The first line contains three integers, n, m, d, with spaces between them. The next line contains the numbers of the positions of the ripe tomatoes, m_i, in ascending order.

Output

The output is provided in the file OUTPUT.TXT, which contains only one line. On this line, you should write the number of unripe tomatoes after d days.

Example of Input - Output File:

STDIN (INPUT.TXT)

19 3 2
2 13 15

STDOUT (OUTPUT.TXT)

8
Note:

The name of the executable file to be created is tomato1.exe.
ATTENTION! You must strictly adhere to the names and structure of the files; otherwise, your answer will be considered incorrect during evaluation.


Comments

There are no comments at the moment.