結果

問題 No.1373 Directed Operations
ユーザー t33ft33f
提出日時 2021-02-05 22:03:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 1,339 ms
コンパイル使用メモリ 80,264 KB
実行使用メモリ 4,444 KB
最終ジャッジ日時 2023-09-15 08:12:35
合計ジャッジ時間 3,892 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 150 ms
4,376 KB
testcase_03 AC 18 ms
4,376 KB
testcase_04 AC 31 ms
4,436 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 166 ms
4,440 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 20 ms
4,376 KB
testcase_09 AC 36 ms
4,380 KB
testcase_10 AC 30 ms
4,380 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 30 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 168 ms
4,376 KB
testcase_15 AC 145 ms
4,380 KB
testcase_16 AC 169 ms
4,444 KB
testcase_17 AC 118 ms
4,380 KB
testcase_18 AC 68 ms
4,380 KB
testcase_19 AC 67 ms
4,380 KB
testcase_20 AC 94 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    pair<int, int> a[n-1];
    for (int i = 0; i < n-1; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a, a+n-1);
    vector<int> ans(n-1);
    for (int i = 0; i < n-1; i++) {
        if (i + 2 - a[i].first <= 0) { cout << "NO\n"; return 0; }
        else ans[a[i].second] = i + 2 - a[i].first;
    }
    cout << "YES\n";
    for (int x : ans) cout << x << endl;
}
0