Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
142416 周震东 音乐会 C++ 通过 100 39 MS 244 KB 630 2024-04-07 22:04:18

Tests(10/10):


#include <algorithm> #include <cstdio> #include <iostream> #include <stack> using namespace std; typedef long long llint; typedef pair<int,int> par; stack<par> S; int main( void ) { int n; scanf( "%d", &n ); llint ret = 0; for( int i = 0; i < n; ++i ) { int h; scanf( "%d", &h ); par p( h, 1 ); for( ; !S.empty() && S.top().first <= h; S.pop() ) { ret += S.top().second; if( S.top().first == h ) p.second += S.top().second; } if( !S.empty() ) ++ret; S.push( p ); } cout << ret << endl; return 0; }


测评信息: