洛谷 P1317 低洼地

P1317 低洼地

模拟

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define maxn 1000000
 4 
 5 int n,h[maxn],tot;
 6 bool if_;
 7 char ch;
 8 inline void read(int &now)
 9 {
10     ch=getchar(); now=0;
11     while(ch>'9'||ch<'0') ch=getchar();
12     while(ch>='0'&&ch<='9') now=now*10+ch-'0',ch=getchar();
13 }
14 
15 int main()
16 {
17     read(n);
18     for(int i=1;i<=n;i++) read(h[i]);
19     for(int i=1;i<=n;i++)
20     {
21         if(!if_&&h[i]<h[i-1]) if_=1;
22         if(if_&&h[i]>h[i-1]) if_=0,tot++;
23     }
24     printf("%d\n",tot);
25     return 0;
26 }
View Code

 

posted @ 2017-09-06 19:16  Alex丶Baker  阅读(486)  评论(0编辑  收藏  举报