T了哇
查看原帖
T了哇
482610
Mortidesperatslav楼主2023/8/30 14:35
#include<bits/stdc++.h>
using namespace std;
long long x,n,ans;
stack<long long>s;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n;
    while(n-->0){
        cin>>x;
		long long t=1;
        while(s.size()&&x>=s.top()){
            if(s.top()==x)t++;
            ans++;s.pop();
        }
        if(s.size())ans++; 
        while(t--)s.push(x); 
    }
    cout<<ans;
}

80pts TLE,求调。

2023/8/30 14:35
加载中...