結果

問題 No.1373 Directed Operations
ユーザー shu8Creamshu8Cream
提出日時 2021-02-06 12:13:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 2,293 ms
コンパイル使用メモリ 205,908 KB
実行使用メモリ 4,436 KB
最終ジャッジ日時 2023-09-15 16:42:13
合計ジャッジ時間 5,295 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 143 ms
4,436 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 14 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 144 ms
4,376 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 18 ms
4,376 KB
testcase_10 AC 16 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 16 ms
4,376 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 145 ms
4,376 KB
testcase_15 AC 126 ms
4,380 KB
testcase_16 AC 147 ms
4,376 KB
testcase_17 AC 109 ms
4,376 KB
testcase_18 AC 63 ms
4,376 KB
testcase_19 AC 61 ms
4,380 KB
testcase_20 AC 81 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
*    author:  shu8Cream
*    created: 05.02.2021 22:21:24
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<P> a(n-1);
    rep(i,n-1){
        cin >> a[i].first;
        a[i].second=i;
    }
    sort(all(a));
    rep(i,n-1){
        if(a[i].first>(i+1)){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    vi ans(n-1);
    rep(i,n-1) ans[a[i].second]=(i+2)-a[i].first;
    rep(i,n-1) cout << ans[i] << endl;
}
0