結果

問題 No.1373 Directed Operations
ユーザー kotatsugamekotatsugame
提出日時 2021-02-05 21:33:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 703 ms
コンパイル使用メモリ 75,984 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 11:45:30
合計ジャッジ時間 3,543 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
int ans[1<<17];
main()
{
	cin>>N;
	vector<pair<int,int> >A(N-1);
	for(int i=0;i<N-1;i++)
	{
		cin>>A[i].first;
		A[i].second=i;
	}
	sort(A.begin(),A.end());
	for(int i=0;i<N-1;i++)
	{
		if(A[i].first>i+1)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		ans[A[i].second]=i+2-A[i].first;
	}
	cout<<"YES"<<endl;
	for(int i=0;i<N-1;i++)cout<<ans[i]<<endl;
}
0