結果

問題 No.1373 Directed Operations
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-02-05 21:35:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 1,566 bytes
コンパイル時間 4,323 ms
コンパイル使用メモリ 263,916 KB
実行使用メモリ 5,532 KB
最終ジャッジ日時 2023-09-15 07:19:29
合計ジャッジ時間 7,204 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 142 ms
5,444 KB
testcase_03 AC 11 ms
4,640 KB
testcase_04 AC 14 ms
4,828 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 150 ms
5,380 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 18 ms
4,380 KB
testcase_09 AC 21 ms
5,512 KB
testcase_10 AC 18 ms
5,236 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 18 ms
4,916 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 152 ms
5,532 KB
testcase_15 AC 130 ms
5,136 KB
testcase_16 AC 151 ms
5,380 KB
testcase_17 AC 108 ms
4,868 KB
testcase_18 AC 64 ms
4,376 KB
testcase_19 AC 61 ms
4,380 KB
testcase_20 AC 87 ms
4,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
//const ll mod = 998244353;
const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }

int main() {
  /* mod は 1e9+7 */
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(10);
  ll n;
  cin>>n;
  vector<pair<ll,ll>> a(n-1);
  for(int i=0;i<n-1;i++){
    cin>>a[i].first;
    a[i].second=i;
  }
  sor(a);
  if(a[0].first!=1){
    cout<<"NO"<<endl;
    return 0;
  }
  vector<ll> ans(n-1);
  for(int i=0;i<n-1;i++){
    ans[a[i].second]=i-a[i].first+2;
    if(i-a[i].first+2<=0){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  for(int i=0;i<n-1;i++){
    cout<<ans[i]<<endl;
  }
}
0