結果

問題 No.1373 Directed Operations
ユーザー elphe
提出日時 2024-11-20 18:02:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 80,936 KB
最終ジャッジ日時 2025-02-25 05:32:16
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	uint32_t N, i;
	cin >> N;
	vector<pair<uint32_t, uint32_t>> a(N - 1);
	for (i = 0; i != N - 1; ++i) cin >> a[i].first;
	for (i = 0; i != N - 1; ++i) a[i].second = i;

	vector<uint32_t> ans(N - 1);
	sort(a.begin(), a.end());
	for (i = 0; i != N - 1; ++i)
	{
		if (a[i].first >= i + 2)
		{
			cout << "NO\n";
			return 0;
		}

		ans[a[i].second] = i + 2 - a[i].first;
	}

	cout << "YES\n";
	for (i = 0; i != N - 1; ++i)
		cout << ans[i] << '\n';

	return 0;
}
0