結果
問題 | No.1438 Broken Drawers |
ユーザー |
![]() |
提出日時 | 2021-03-26 21:24:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 528 bytes |
コンパイル時間 | 742 ms |
コンパイル使用メモリ | 70,784 KB |
実行使用メモリ | 6,016 KB |
最終ジャッジ日時 | 2024-11-28 21:23:47 |
合計ジャッジ時間 | 3,065 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <algorithm> #include <iostream> using namespace std; typedef pair<int, int> P; int main() { int n; cin >> n; int a[200005]; P p[200005]; for(int i = 0; i < n; i++){ cin >> a[i]; p[i] = P(a[i], i); } sort(p, p + n); bool b[200005]; for(int i = 0; i < n; i++) b[i] = true; int ans = 0; for(int i = 0; i < n; i++){ if(b[p[i].second]){ ans++; if(p[i].second) b[p[i].second - 1] = false; } } cout << ans << endl; }