結果

問題 No.1373 Directed Operations
ユーザー seiyuseiyu
提出日時 2021-02-05 22:35:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 1,480 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 174,656 KB
実行使用メモリ 5,000 KB
最終ジャッジ日時 2023-09-15 09:06:01
合計ジャッジ時間 4,676 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 144 ms
4,880 KB
testcase_03 AC 10 ms
4,376 KB
testcase_04 AC 13 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 159 ms
4,884 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 19 ms
4,376 KB
testcase_09 AC 21 ms
5,000 KB
testcase_10 AC 17 ms
4,520 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 16 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 158 ms
4,852 KB
testcase_15 AC 137 ms
4,748 KB
testcase_16 AC 163 ms
4,852 KB
testcase_17 AC 116 ms
4,772 KB
testcase_18 AC 66 ms
4,376 KB
testcase_19 AC 62 ms
4,376 KB
testcase_20 AC 88 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int n;
    cin >> n;

    vector<bool> visited(n, 0);

    vector<pair<int,int>> a(n - 1);

    rep(i, n - 1){
        int a_now;
        cin >> a_now;
        a[i] = make_pair(a_now, i);
    }

    sort(a.begin(), a.end());

    visited[0] = true;

    vector<pair<int,int>> ans;

    FOR(i,1,n){
        int now_index = i ;
        int now_index_to = i- a[i - 1].first;
        if(now_index_to < 0){
            cout << "NO" << endl;
            return 0;
        }
        if(visited[now_index_to]){
            visited[now_index] = true;
            ans.push_back({a[i - 1].second,now_index_to + 1});
        }
    }

    cout << "YES" << endl;

    sort(ans.begin(), ans.end());

    rep(i, int(ans.size())){
        cout << ans[i].second << endl;
    }

    return 0;
}
0