Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
142099 | 梁乃元 | 音乐会 | C++ | 通过 | 100 | 89 MS | 8072 KB | 646 | 2024-04-06 16:35:08 |
#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 << endl ; return 0 ; }