結果

問題 No.1373 Directed Operations
ユーザー 沙耶花沙耶花
提出日時 2021-02-05 21:27:00
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 205,972 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 07:10:26
合計ジャッジ時間 5,143 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 146 ms
4,380 KB
testcase_03 AC 18 ms
4,376 KB
testcase_04 AC 31 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 163 ms
4,376 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 20 ms
4,376 KB
testcase_09 AC 37 ms
4,380 KB
testcase_10 AC 32 ms
4,376 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 31 ms
4,376 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 165 ms
4,376 KB
testcase_15 AC 143 ms
4,380 KB
testcase_16 AC 164 ms
4,380 KB
testcase_17 AC 117 ms
4,380 KB
testcase_18 AC 67 ms
4,380 KB
testcase_19 AC 66 ms
4,380 KB
testcase_20 AC 93 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001


int main(){
	
	int N;
	cin>>N;
	
	vector<pair<int,int>> a(N-1);
	
	rep(i,N-1){
		cin>>a[i].first;
		a[i].second = i;
	}
	
	sort(a.begin(),a.end());
	vector<int> ans(N-1);
	rep(i,N-1){
		int t = i+2;
		ans[a[i].second] = t - a[i].first;
		if(ans[a[i].second]<=0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	rep(i,N-1){
		cout<<ans[i]<<endl;
	}
	
	return 0;
}
0