結果

問題 No.1373 Directed Operations
ユーザー soto800soto800
提出日時 2021-02-05 22:10:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,455 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 166,440 KB
実行使用メモリ 6,328 KB
最終ジャッジ日時 2023-09-15 08:22:24
合計ジャッジ時間 5,985 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,500 KB
testcase_02 AC 151 ms
5,628 KB
testcase_03 AC 18 ms
5,440 KB
testcase_04 AC 30 ms
5,360 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 166 ms
6,312 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 19 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 26 ms
5,736 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<28)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define MOD (1000000007)
#define TO_STRING(VariableName) # VariableName
#define LOG(xx) if(DEBUG)cout<<TO_STRING(xx)<<"="<<xx<<" "<<endl;
#define LOG2(xx,yy) if(DEBUG)cout<<TO_STRING(xx)<<"="<<xx<<" "<<TO_STRING(yy)<<"="<<yy<<endl;
#define LOG3(xx,yy,z) if(DEBUG)cout<<TO_STRING(xx)<<"="<<xx<<" "<<TO_STRING(yy)<<"="<<yy<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,xx,yy,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(xx)<<"="<<xx<<" "<<TO_STRING(yy)<<"="<<yy<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool vis[100100];
lli cnt[100100];
lli start[100100];

int main(){

	lli n;
	cin>>n;
	vector<lli> a(n-1);
	vector<lli> ans(n-1);
	REP(i,0,n-1){
		lli num;
		cin>>num;
		a[i] = num;
		cnt[num]++;
	}
	REP(i,0,n){
		start[i] = 1;
	}

	for(lli i=1;i<=n;i++){
		if(cnt[n-i] > i){
			cout<<"NO"<<endl;
			return 0;
		}
	}

	cout<<"YES"<<endl;
	REP(i,0,n-1){
		if(start[a[i]]+a[i] > n){
			cout<<n-a[i]<<endl;
		}
		else{
			cout<<start[a[i]]<<endl;
		}
		start[a[i]] += a[i];
	}

    return 0;
}
0