結果

問題 No.1373 Directed Operations
ユーザー izryt(趣味)izryt(趣味)
提出日時 2021-02-06 11:50:05
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,933 bytes
コンパイル時間 1,374 ms
コンパイル使用メモリ 119,636 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-15 16:16:01
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 26 ms
4,376 KB
testcase_03 AC 19 ms
4,380 KB
testcase_04 AC 31 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 45 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 6 ms
4,384 KB
testcase_09 AC 37 ms
4,376 KB
testcase_10 AC 32 ms
4,380 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 31 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 45 ms
4,376 KB
testcase_15 AC 39 ms
4,376 KB
testcase_16 AC 45 ms
4,388 KB
testcase_17 AC 24 ms
4,380 KB
testcase_18 AC 13 ms
4,376 KB
testcase_19 AC 18 ms
4,380 KB
testcase_20 AC 26 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

signed main()
{
    int N; cin >> N;

    vector<pii> a(N-1);
    vi ans(N-1);

    rep(i, N-1) cin >> a[i].first, a[i].second = i;

    sort(all(a));

    int mx = 0;

    rep(i, N-1) {
        int l = a[i].first;

        if (mx + 1 - l < 0) {
            cout << "NO\n";
            return 0;
        }

        ans[a[i].second] = mx + 1 - l;
        mx++;
    }

    printf("YES\n");
    rep(i, N-1) printf("%d\n", ans[i]+1);
}
0