結果
問題 | No.1373 Directed Operations |
ユーザー | Mister |
提出日時 | 2021-02-05 23:20:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 765 bytes |
コンパイル時間 | 1,035 ms |
コンパイル使用メモリ | 79,656 KB |
最終ジャッジ日時 | 2025-01-18 13:06:05 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#line 1 "main.cpp" #include <iostream> #include <algorithm> #include <numeric> #include <vector> using namespace std; void solve() { int n; cin >> n; vector<int> xs(n - 1); for (auto& x : xs) cin >> x; vector<int> is(n - 1); iota(is.begin(), is.end(), 0); sort(is.begin(), is.end(), [&](int i, int j) { return xs[i] < xs[j]; }); vector<int> ans(n - 1); for (int v = 1; v < n; ++v) { auto i = is[v - 1]; auto x = xs[i]; if (x > v) { cout << "NO\n"; return; } ans[i] = v - x; } cout << "YES\n"; for (auto v : ans) cout << v + 1 << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }