結果

問題 No.1373 Directed Operations
ユーザー RheoTommyRheoTommy
提出日時 2021-02-05 22:32:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 207,868 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2023-09-15 09:02:00
合計ジャッジ時間 5,206 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 152 ms
8,004 KB
testcase_03 AC 20 ms
6,940 KB
testcase_04 AC 32 ms
6,936 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 192 ms
10,112 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 22 ms
4,380 KB
testcase_09 AC 44 ms
9,820 KB
testcase_10 AC 35 ms
7,520 KB
testcase_11 AC 10 ms
4,380 KB
testcase_12 AC 31 ms
6,200 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 185 ms
8,724 KB
testcase_15 AC 161 ms
7,996 KB
testcase_16 AC 188 ms
8,780 KB
testcase_17 AC 117 ms
6,956 KB
testcase_18 AC 68 ms
5,384 KB
testcase_19 AC 75 ms
6,064 KB
testcase_20 AC 106 ms
7,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int) n; i++)

using ll = long long;
using namespace std;

const long long INF = 1ll << 60;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n - 1, 0);
    rep(i, n - 1) cin >> a[i];
    vector<ll> unsorted = a;
    sort(a.begin(), a.end());
    
    ll current = 1;
    vector<vector<ll>> log(n + 1);
    rep(i, n - 1) {
        ll j = current + 1 - a[i];
        if (j >= 1) {
            log[a[i]].push_back(j);
            current++;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    for (auto ai:unsorted) {
        cout << log[ai].back() << endl;
        log[ai].pop_back();
    }
}
0