WA,25pts,玄关求条
查看原帖
WA,25pts,玄关求条
1105009
Yangxixuan楼主2025/7/22 11:30
#include <cstdio>
#include <iostream>
#include <stack>
#define ll long long
using namespace std;
int n;
ll ans=0,k=0,x=0;
stack<ll>st;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		while(!st.empty()&&st.top()<x){
			k=st.top()*st.size();
			ans=max(ans,k);
			st.pop();
		}
		st.push(x);
		k=st.top()*st.size();
		ans=max(ans,k);
	}
	printf("%lld",ans);
	return 0;
}
2025/7/22 11:30
加载中...