結果
| 問題 |
No.1373 Directed Operations
|
| コンテスト | |
| ユーザー |
wotsushi
|
| 提出日時 | 2020-11-04 22:11:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 618 bytes |
| コンパイル時間 | 2,282 ms |
| コンパイル使用メモリ | 195,820 KB |
| 最終ジャッジ日時 | 2025-01-15 19:50:19 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 TLE * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
// 各操作を先読みしない解法
// O(N^2) がTLEになるかチェック
int main() {
int N;
cin >> N;
vector<bool> used(N + 1);
vector<int> x(N);
for (int i = 1; i <= N - 1; ++i) {
int a;
cin >> a;
bool ok = false;
for (int j = a + 1; j <= N; ++j) {
if (not used[j]) {
x[i] = j - a;
used[j] = true;
ok = true;
break;
}
}
if (not ok) {
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
for (int i = 1; i <= N - 1; ++i) {
cout << x[i] << endl;
}
}
wotsushi