90分,求助
  • 板块P1317 低洼地
  • 楼主transize
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/11/10 16:16
  • 上次更新2024/11/10 18:50:22
查看原帖
90分,求助
1396682
transize楼主2024/11/10 16:16
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, cnt = 0;
	cin >> n;
	vector<int> a(n);
	vector<bool> b;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] < a[i - 1]) b.push_back(false);
		else b.push_back(true);
	}
	bool s = false;
	for (int i = 1; i < n - 1; i++) {
		if (b[i] == false) s = true;
		else if (b[i] == true && s == true) {
			cnt++, s = false;
		}
	}
	cout << cnt;
	return 0;
}
2024/11/10 16:16
加载中...