結果
問題 |
No.2036 Max Middle
|
ユーザー |
![]() |
提出日時 | 2022-08-12 21:54:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 542 bytes |
コンパイル時間 | 367 ms |
コンパイル使用メモリ | 51,200 KB |
実行使用メモリ | 15,392 KB |
最終ジャッジ日時 | 2024-09-23 02:20:44 |
合計ジャッジ時間 | 4,060 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 4 TLE * 1 -- * 12 |
ソースコード
#include <stdio.h> #include <set> int x[200010]; std::set< std::pair<int,int> > S; int main() { int ans = 0; int a; scanf("%d",&a); for(int i=1;i<=a;i++) scanf("%d",&x[i]); for(int i=2;i<=a-1;i++) S.insert(std::make_pair(x[i],i)); while(!S.empty()) { std::set< std::pair<int,int> > ::iterator it = S.end(); it--; int ind = (it->second); S.erase(it); if(x[ind-1]<x[ind] && x[ind]>x[ind+1]) { ans++; x[ind] = (x[ind-1]<x[ind+1]?x[ind-1]:x[ind+1])-1; S.insert(std::make_pair(x[ind],ind)); } } printf("%d",ans); }