結果
問題 | No.1438 Broken Drawers |
ユーザー |
![]() |
提出日時 | 2021-03-26 21:35:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 232 ms / 2,000 ms |
コード長 | 491 bytes |
コンパイル時間 | 854 ms |
コンパイル使用メモリ | 86,808 KB |
実行使用メモリ | 14,208 KB |
最終ジャッジ日時 | 2024-11-28 22:12:55 |
合計ジャッジ時間 | 5,464 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <iostream> #include <vector> #include <map> #include <algorithm> using namespace std; int main(){ int n,ans=0; cin>>n; vector<int> a(n),used(n,0); map<int,int> place; for(int i=0;i<n;i++){ cin>>a[i]; place[a[i]]=i; } sort(a.begin(),a.end()); for(int ai:a){ if(used[place[ai]]) continue; int pi=place[ai]; used[pi]=1; if(pi>0) used[pi-1]=1; ans++; } cout<<ans<<endl; return 0; }