結果
| 問題 |
No.1438 Broken Drawers
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-20 00:52:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 67 ms / 2,000 ms |
| コード長 | 485 bytes |
| コンパイル時間 | 1,620 ms |
| コンパイル使用メモリ | 171,888 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-04 05:13:27 |
| 合計ジャッジ時間 | 3,817 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
int main() {
int n;
cin >> n;
vector<int> a(n), pre(n, -1);
rep(i, n) {
cin >> a[i];
a[i]--;
if (i > 0) pre[a[i]] = a[i-1];
}
vector<bool> used(n, true);
int ans = 0;
rep(i, n) {
if (used[i]) {
ans++;
used[i] = false;
if (pre[i] != -1) used[pre[i]] = false;
}
}
cout << ans << endl;
}