結果
問題 |
No.1373 Directed Operations
|
ユーザー |
|
提出日時 | 2022-10-09 17:36:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 38 ms / 2,000 ms |
コード長 | 775 bytes |
コンパイル時間 | 2,236 ms |
コンパイル使用メモリ | 203,864 KB |
最終ジャッジ日時 | 2025-02-08 00:47:37 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector<pair<int,int>> a(N-1); for(int i = 1; i <= N - 1; i++) { cin >> a[i-1].first; a[i-1].second = i; } sort(a.begin(), a.end()); int ok = 1; for(int i = 1; i <= N - 1; i++) ok &= (a[i-1].first <= i); if(ok) { cout << "YES" << endl; for(int i = 1; i <= N - 1; i++) a[i-1].first = (i + 1) - a[i-1].first; sort(a.begin(), a.end(), [](auto I, auto J){ return I.second < J.second; }); for(int i = 1; i <= N - 1; i++) cout << a[i - 1].first << "\n"; } else { cout << "NO" << endl; } }