没有AC这道题的孩子,或许还有?救救孩子。。。
  • 板块灌水区
  • 楼主Lovelace_qwq
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/8/27 23:16
  • 上次更新2024/8/28 10:12:42
查看原帖
没有AC这道题的孩子,或许还有?救救孩子。。。
1223290
Lovelace_qwq楼主2024/8/27 23:16

p1823

#include<iostream>
using namespace std;
long n,top,ans,h,t;
long s[1000100];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&h);
		t=1;
		while(top&&h>=s[top]){
			if(s[top]==h)t++;
			ans++;
			--top;
		}
		if(top)ans++;
		while(t){
			s[++top]=h;
			t--;
		}
	}
	cout<<ans;
}
2024/8/27 23:16
加载中...