結果
問題 |
No.1373 Directed Operations
|
ユーザー |
![]() |
提出日時 | 2021-02-05 22:10:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,455 bytes |
コンパイル時間 | 1,605 ms |
コンパイル使用メモリ | 168,932 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-07-02 12:39:08 |
合計ジャッジ時間 | 5,463 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 11 |
ソースコード
#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; }