結果
問題 | No.1373 Directed Operations |
ユーザー |
![]() |
提出日時 | 2021-02-05 22:32:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 189 ms / 2,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 2,118 ms |
コンパイル使用メモリ | 201,724 KB |
最終ジャッジ日時 | 2025-01-18 12:40:48 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#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(); } }