10分求救!(只对了样例)

P1317 低洼地

@[henry09](/space/show?uid=176101) 我记得我做的时候要把开头和末尾去掉....
by foxdemon @ 2019-05-15 12:05:03


@[foxdemon](/space/show?uid=110278) 我这个去不去头尾都不影响结果,错的是210这个组合
by henry09 @ 2019-05-15 19:03:58


```cpp #include<bits/stdc++.h> using namespace std ; int s[10005] ; int main() { int n = 0 , sum = 0 , i ; cin >> n ; for ( i = 1 ; i <= n ; i++ ) { cin >> s[i] ; } int a = 1 ; while ( a <= n ) { while ( s[a] <= s[a - 1] ) a++ ; while ( s[a] >= s[a - 1] ) a++ ; sum++ ; } cout << sum - 2 << endl ; return 0 ; } ``` emmmmm,这是我的
by foxdemon @ 2019-05-15 20:55:20


@[henry09](/space/show?uid=176101) 你再看看咯,我也是个蒟蒻..
by foxdemon @ 2019-05-15 20:55:55


@[foxdemon](/space/show?uid=110278) 你的程序我测的是RE
by henry09 @ 2019-05-16 17:32:03


@[henry09](/space/show?uid=176101) 以前过得,应该是被改了,我重新做一下嗷...
by foxdemon @ 2019-05-16 18:30:17


```cpp #include<bits/stdc++.h> using namespace std ; int main() { int n , ans = 0 , last = 0 , h ; bool sx = 1 ;//判断上下坡,然后第一个一定是上坡,1就是上坡了 cin >> n ; for ( int i = 1 ; i <= n ; i++ ) { if ( i == 1 )//第一个点特判一下下 { last = 0 ; } cin >> h ; if ( h < last && sx == 0 )//如果这个比上个点要低,并且是下坡,成立 { ans++ ; sx = 1 ; } else if ( h > last && sx == 1 ) { sx = 0 ; } last = h ;//将last赋值为现在的高度 //这样写不需要判断相等 来着 } if ( sx == 1 )//结束循环的时候如果是上坡,没有水坑坑,减去一个 { ans-- ; } cout << ans << endl ; return 0 ; } ```
by foxdemon @ 2019-05-16 19:17:20


@[henry09](/space/show?uid=176101) 你看下这个呐,这个ac了
by foxdemon @ 2019-05-16 19:17:43


```cpp #include <iostream> using namespace std; int main() { int n,a[100001],temp; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; if(i>=1) if(a[i]<a[i-1]&&a[i]<a[i+1]) temp++; } cout<<temp; return 0; } ``` I am a 蒟蒻 too.
by D447H @ 2019-07-30 12:36:06


@[78_Minecraft_87](/user/229450) 你这个肯定不对,输入时就有问题
by hfwangcl @ 2020-01-13 21:04:08


|