Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
119523 陈家宝 音乐会 C++ 通过 100 142 MS 8072 KB 470 2024-01-08 13:10:22

Tests(10/10):


#include<bits/stdc++.h> using namespace std; long long n,cnt=0; struct pl { long long h,c=1; }o[500050]; stack<pl> q; int main() { cin>>n; for(int i=1;i<=n;i++){ cin >> o [i] . h; while(! q . empty () && o [i] . h >= q . top () . h){ cnt += q . top () . c; if(o [i] . h == q . top () . h)o [i] . c += q . top () . c; q . pop (); } if(! q . empty ())cnt++; q.push( o [i] ); } cout<<cnt; return 0; }


测评信息: