結果

問題 No.1373 Directed Operations
ユーザー 👑 NachiaNachia
提出日時 2021-02-05 22:08:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 1,993 ms
コンパイル使用メモリ 202,936 KB
実行使用メモリ 4,752 KB
最終ジャッジ日時 2023-09-15 08:18:34
合計ジャッジ時間 4,142 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 21 ms
4,748 KB
testcase_03 AC 12 ms
4,376 KB
testcase_04 AC 14 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 29 ms
4,688 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 20 ms
4,376 KB
testcase_10 AC 17 ms
4,380 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 17 ms
4,380 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 30 ms
4,752 KB
testcase_15 AC 27 ms
4,552 KB
testcase_16 AC 30 ms
4,684 KB
testcase_17 AC 19 ms
4,416 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 12 ms
4,376 KB
testcase_20 AC 16 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;
pair<int,int> A[100000];
int ans[100000];

int main(){
  scanf("%d",&N);
  rep(i,N-1){ int a; scanf("%d",&a); A[i]={a,i}; }
  sort(A,A+N-1);
  rep(i,N-1) if(A[i].first>i+1){ printf("NO\n"); return 0; }
  rep(i,N-1) ans[A[i].second]=i+2-A[i].first;
  printf("YES\n");
  rep(i,N-1){ if(i) printf(" "); printf("%d",ans[i]); } printf("\n");
  return 0;
}

0