Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
143852 陈家宝 音乐会 C++ 通过 100 106 MS 8068 KB 450 2024-04-19 13:22:34

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; }


测评信息: