結果

問題 No.1373 Directed Operations
ユーザー shu8Creamshu8Cream
提出日時 2021-02-06 12:05:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 205,512 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 16:33:25
合計ジャッジ時間 5,409 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 142 ms
4,376 KB
testcase_03 AC 10 ms
4,376 KB
testcase_04 AC 13 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 154 ms
4,376 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 18 ms
4,380 KB
testcase_09 AC 18 ms
4,380 KB
testcase_10 AC 16 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 16 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 156 ms
4,376 KB
testcase_15 AC 136 ms
4,376 KB
testcase_16 AC 155 ms
4,380 KB
testcase_17 AC 113 ms
4,376 KB
testcase_18 AC 65 ms
4,376 KB
testcase_19 AC 62 ms
4,376 KB
testcase_20 AC 85 ms
4,376 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;
    rep(i,n-1) a[i].first=(i+2)-a[i].first;
    rep(i,n-1) swap(a[i].first,a[i].second);
    sort(all(a));
    rep(i,n-1) cout << a[i].second << endl;
}
0