結果

問題 No.1373 Directed Operations
ユーザー wotsushiwotsushi
提出日時 2020-11-04 22:11:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 618 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 200,880 KB
実行使用メモリ 8,372 KB
最終ジャッジ日時 2023-09-29 16:21:40
合計ジャッジ時間 6,202 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  }
}
0