80pts求助!!!!!!!!!!!!!!!!!!
查看原帖
80pts求助!!!!!!!!!!!!!!!!!!
772284
Justskr楼主2024/3/3 12:31
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
ll n,h[10086],maxn;
int main(){
	//ios::sync_with_stdio(false);
	//cin.tie(0),cout.tie(0);
	cin >> n;
	for(ll i = 1;i <= n;i++){
		cin >> h[i];
		maxn = max(h[i],maxn);
	}
	ll he = 0,s = 0,cnt = 0;
	while(he <= maxn){
		he++;
		for(ll i = 1;i <= n;i++){
			if(h[i] >= he){
				s++;
			}else{
				if(s > 0){
					cnt++;
					s = 0;
				}
			}
		}
		if(s>0){
			cnt++;
			s=0;
		}
		//cout << he << " " << cnt << endl;
	}

	cout << cnt;

	return 0;
}

WA最后两个点

2024/3/3 12:31
加载中...