Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
141790 我是傻逼 音乐会 C++ 通过 100 84 MS 260 KB 573 2024-04-06 11:10:10

Tests(10/10):


#include<bits/stdc++.h> using namespace std; const int maxn = 500001; int push[maxn],num[maxn]; long long ans=0; int main(){ int n,i,k,p=1,t; cin>>n>>k; push[0]=0x7fffffff; num[0]=0; push[1]=k; num[1]=1; for(i=2;i<=n;i++){ cin>>k; if(k<push[p]){ ans++; p++; push[p]=k; num[p]=1; } else{ t=0; while(push[p]<=k){ t+=num[p]; p--; } if(p!=0){ t++; } p++; if(push[p]==k){ num[p]++; } else{ push[p]=k; num[p]=1; } ans+=t; } } cout<<ans; return 0; }


测评信息: