結果

問題 No.1373 Directed Operations
ユーザー poohbearpoohbear
提出日時 2021-02-05 21:48:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 2,369 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 209,280 KB
実行使用メモリ 6,308 KB
最終ジャッジ日時 2023-09-15 07:59:39
合計ジャッジ時間 5,438 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 150 ms
6,304 KB
testcase_03 AC 20 ms
6,308 KB
testcase_04 AC 32 ms
6,192 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 169 ms
6,216 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 19 ms
4,376 KB
testcase_09 AC 39 ms
6,244 KB
testcase_10 AC 33 ms
5,676 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 33 ms
5,788 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 169 ms
6,240 KB
testcase_15 AC 147 ms
5,780 KB
testcase_16 AC 168 ms
6,140 KB
testcase_17 AC 118 ms
5,668 KB
testcase_18 AC 69 ms
4,388 KB
testcase_19 AC 67 ms
4,460 KB
testcase_20 AC 95 ms
4,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
const ll INF = 1e18+7;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template<typename T> 
inline void prt(vector<vector<T> >& vv){ for(const auto& v : vv){ prt(v); } }
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

/*
方針
sortした状態で考える

*/


int main(){
	ll n;
	cin >> n;
	vector<ll>a(n-1);
	rep(i,n-1)cin>>a[i];
	vector<P>v(n-1);
	rep(i,n-1)v[i]={a[i],i};
	sort(v.begin(),v.end());
	vector<ll>ans(n-1);
	vector<bool>done(n);
	done[0]=true;
	rep(i,n-1){
		if(i+1-v[i].first<0){
			cout << "NO" << endl;
			return 0;
		}
		done[i+1-v[i].first]=true;
		ans[v[i].second]=i+2-v[i].first;
		//cout << ans[v[i].second] << endl;
	}
	cout << "YES" << endl;
	rep(i,n-1){
		cout << ans[i] << endl;
	}
	//debug(ans);
	return 0;
}
0