AmazonOA #230
Get Minimum Number of Unique Distribution Centers
估计中等可在线判题
On day i, choose a center numbered 1..n. If demand is higher than on the previous day, the center number must be strictly higher; if demand is lower, it must be strictly lower; if demand is equal, the same center must be used. Minimize the number of distinct centers used over all days.
输入格式
The first line contains n; the second line contains each day's demand. The original text had no numeric bounds; this site uses 1≤n≤200000, 0≤demand≤10^9.
输出格式
Output a single integer, the answer.
样例 1
输入:
5
10 20 30 15 10
输出:
3
样例 2
输入:
4
1 2 2 3
输出:
3
样例 3
输入:
2
5 5
输出:
1
样例说明
The answers are 3, 3 and 1. Equal demands do not interrupt a continuing rising constraint.