結果

問題 No.1373 Directed Operations
ユーザー kotatsugame
提出日時 2021-02-05 21:32:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 424 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 76,124 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 11:44:37
合計ジャッジ時間 4,412 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
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[i]=i+2-A[i].first;
	}
	cout<<"YES"<<endl;
	for(int i=0;i<N-1;i++)cout<<ans[i]<<endl;
}
0