結果
問題 | No.1373 Directed Operations |
ユーザー |
![]() |
提出日時 | 2021-02-05 21:36:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 167 ms / 2,000 ms |
コード長 | 725 bytes |
コンパイル時間 | 1,993 ms |
コンパイル使用メモリ | 201,976 KB |
最終ジャッジ日時 | 2025-01-18 12:04:18 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = (1LL << 61); ll mod = 998244353; signed main() { ios::sync_with_stdio(false); cin.tie(0); ll N; cin >> N; vector<ll>a(N - 1); for (int i = 0; i < N - 1; i++)cin >> a[i]; vector<ll>ans(N - 1, -1); set<P>st; for (int i = 0; i < N - 1; i++) { st.insert({ a[i], i }); } for (int i = 0; i < N - 1 ; i++) { auto idx = st.upper_bound({ i + 2, -INF }); if (idx == st.begin()) { cout << "NO" << endl; return 0; } idx--; P tmp = *idx; ans[tmp.second] = i + 2 - tmp.first; st.erase(idx); } cout << "YES" << endl; for (int i = 0; i < N - 1; i++) { cout << ans[i] << endl; } return 0; }