#P14632. [2018 KAIST RUN Fall] Rising Sun
[2018 KAIST RUN Fall] Rising Sun
题目描述
Joon has a midterm exam tomorrow, but he hasn't studied anything. So he decided to stay up all night to study. He promised himself that he will not stop studying before the sun rises.
Joon's house is in some mountains. For convenience, let's say that Joon is living in a 2-dimensional coordinate system. The mountains are in the region , starting at , and the boundary of them consists of line segments parallel to either or .
More precisely, the boundary of the mountains can be described by additional integers, where the th number of them is the -coordinate of the th cusp of the mountains. The boundary line starts at , proceeds parallel to until its -coordinate reaches , then proceeds parallel to until its -coordinate reaches , and so on. After the last step, the line proceeds parallel to until it meets the -axis.
The interior of the mountains is the region below the boundary and above the -axis. Thus, the interior and the boundary are disjoint.
At some point between and , there is Joon's house on the boundary of the mountains. The size of his house is neglectable compared to the mountains.
Currently, the sun is at the origin and it rises vertically ( direction), 1 per minute. Joon can see the sun if the interior of the mountains does not intersect the straight line segment connecting Joon's house and the sun. Joon is completely exhausted and wants to know when can he stop studying. But as you may expect, he is out of his mind, so he cannot do such difficult math. Help him!
输入格式
The first line of the input contains an integer ().
The next line contains integers, the th of which is the integer ().
The last line contains an integer , the -coordinate of Joon's house ().
It is guaranteed that the boundary of the mountains is in the region .
输出格式
Print exactly one integer , the smallest integer such that Joon can see the sun after minutes.
2
1 4 6 7
7
5
2
3 4 5 7
7
0
3
4 9 12 13 14 16
15
8
提示
:::align{center}

Illustration of the first example. :::