40分求助
  • 板块P1317 低洼地
  • 楼主QirErl
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/10/13 03:33
  • 上次更新2024/10/13 11:10:19
查看原帖
40分求助
1512108
QirErl楼主2024/10/13 03:33
#include<bits/stdc++.h>
using namespace std;
int n,a[10005],ans = 0;
bool pd = 1;
int main(){
	cin >> n;
	a[1] = 0;
	a[n] = 0;
	for(int i = 1;i <= n;i++){
		cin >> a[i];

	}
	for(int i = 2;i <= n-1;i++){

		if(a[i] < a[i-1]&&pd == 1){
			ans++;
			pd = 0;
			if(a[i] < a[i+1]){
				pd = 1;
			}
		}else if(a[i] < a[i + 1]){
			pd = 1; 
		}
		
	}
	cout<<ans;
	return 0;
}
2024/10/13 03:33
加载中...