結果

問題 No.1373 Directed Operations
ユーザー Example0911Example0911
提出日時 2021-02-05 21:36:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 207,784 KB
実行使用メモリ 11,140 KB
最終ジャッジ日時 2023-09-15 07:20:18
合計ジャッジ時間 5,386 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 169 ms
10,856 KB
testcase_03 AC 37 ms
11,140 KB
testcase_04 AC 39 ms
10,968 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 186 ms
10,924 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 21 ms
4,384 KB
testcase_09 AC 56 ms
11,092 KB
testcase_10 AC 45 ms
9,652 KB
testcase_11 AC 10 ms
4,932 KB
testcase_12 AC 44 ms
9,324 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 190 ms
10,864 KB
testcase_15 AC 163 ms
9,800 KB
testcase_16 AC 192 ms
11,024 KB
testcase_17 AC 123 ms
8,792 KB
testcase_18 AC 75 ms
6,488 KB
testcase_19 AC 70 ms
6,104 KB
testcase_20 AC 97 ms
7,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0