## Cheerio Contest 1 S3 - Stock Trading

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 512M

Author:
Problem types

Ethan is an avid stock trader. In order to predict future stock prices, he performs technical analysis on stock charts by drawing trendlines. The chart is displayed as a grid with time on the x-axis and price on the y-axis. There are points, where the point is , indicating that at time , the stock price was . Adjacent points are then connected to form a line graph. That is, point is connected to points and .

The line connecting two points and where is considered to be a trendline when all points in the range are either all above/on the line or all below/on the line. Can you help Ethan find the number of different trendlines he can draw? Two trendlines are considered different if they start or end at different points.

Points Awarded
5 points
6 points
4 points

#### Input Specification

The first line contains one integer .

The next lines contain two integers and .

#### Output Specification

Output the number of different trendlines that could be drawn.

#### Sample Input

4
0 0
2 4
5 2
6 5

#### Sample Output

5

#### Explanation for Sample Output

Notice that the line connecting points and is not a trendline.