20分,只AC了五个,求助!!!
查看原帖
20分,只AC了五个,求助!!!
1311985
chasm_pain楼主2024/7/3 09:19
#include<bits/stdc++.h>
using namespace std;
long long q,z[1000005],n[1000005],nl,n1;
stack<int> sb;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>z[i];
		while (!sb.empty()&&z[sb.top()]<z[i])
		{
			nl++;
			sb.pop();
		}
		if(!sb.empty())
		nl++;
		sb.push(i);
	}
	cout<<nl;
}
2024/7/3 09:19
加载中...