记录编号 |
301769 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2013]花匠 |
最终得分 |
100 |
用户昵称 |
Fmuckss |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.050 s |
提交时间 |
2016-09-02 10:07:34 |
内存使用 |
0.25 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define is_num(x) (x <= '9' and x >= '0')
inline int get_num() {
char tmp = getchar();
int res = 0;
while(not is_num(tmp)) tmp = getchar();
while( is_num(tmp)) {
res = res * 10 + tmp - '0';
tmp = getchar();
}
return res;
}
inline void solve() {
int n = get_num(), now = get_num(), tmp, inc = 0, ans = 1;
for(int i = 2; i <= n; i++) {
tmp = get_num();
if(tmp < now and inc != -1) ++ans, inc = -1;
if(tmp > now and inc != 1) ++ans, inc = 1;
now = tmp;
}
printf("%d\n", ans);
}
int main() {
freopen("FlowerNOIP2013.in", "r", stdin);
freopen("FlowerNOIP2013.out", "w", stdout);
solve();
return 0;
}