結果

問題 No.1373 Directed Operations
ユーザー leaf_1415leaf_1415
提出日時 2020-10-08 01:50:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 66,644 KB
実行使用メモリ 5,176 KB
最終ジャッジ日時 2023-09-28 00:36:22
合計ジャッジ時間 5,584 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 18 ms
4,680 KB
testcase_04 AC 30 ms
4,864 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 37 ms
4,976 KB
testcase_10 AC 31 ms
4,776 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 30 ms
4,416 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cassert>
#include <vector>
#include <utility>
#include <algorithm>
#include <ctime>

using namespace std;
typedef pair<int, int> P;

int n;
int a[100005];
P p[100005];
int ans[100005];

int main()
{
	cin >> n;
	assert(n >= 2 && n <= 100000);
	for(int i = 1; i <= n-1; i++){
		cin >> a[i];
		assert(a[i] >= 1 && a[i] <= n-1);
	}
	
	for(int i = 1; i <= n-1; i++) p[i] = P(a[i], i);
	sort(p+1, p+n);
	
	for(int i = 1; i <= n-1; i++){
		if(p[i].first > i){
			cout << "NO" << endl;
			return 0;
		}
		ans[p[i].second] = (i+1) - a[p[i].second];
	}
	
	cout << "YES" << endl;
	for(int i = 1; i <= n-2; i++) cout << ans[i] << endl;
	
	return 0;
}
0