結果

問題 No.1017 Reiwa Sequence
ユーザー kyort0nkyort0n
提出日時 2020-04-04 05:00:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
J_TLE  
(最初)
実行時間 -
コード長 1,638 bytes
コンパイル時間 1,765 ms
コンパイル使用メモリ 180,820 KB
実行使用メモリ 107,424 KB
最終ジャッジ日時 2023-09-16 05:24:22
合計ジャッジ時間 29,256 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 11 ms
4,668 KB
testcase_13 AC 7 ms
4,384 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 21 ms
6,080 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 1,149 ms
107,344 KB
testcase_20 AC 1,251 ms
107,288 KB
testcase_21 AC 1,286 ms
107,312 KB
testcase_22 AC 1,245 ms
107,424 KB
testcase_23 AC 1,213 ms
107,284 KB
testcase_24 AC 1,235 ms
107,320 KB
testcase_25 AC 1,196 ms
107,312 KB
testcase_26 AC 937 ms
107,360 KB
testcase_27 AC 547 ms
54,460 KB
testcase_28 AC 110 ms
15,560 KB
testcase_29 AC 8 ms
4,376 KB
testcase_30 AC 561 ms
53,960 KB
testcase_31 AC 28 ms
6,980 KB
testcase_32 AC 524 ms
54,160 KB
testcase_33 AC 430 ms
53,916 KB
testcase_34 AC 477 ms
53,912 KB
testcase_35 AC 472 ms
53,908 KB
testcase_36 AC 477 ms
53,884 KB
testcase_37 AC 556 ms
53,916 KB
testcase_38 AC 550 ms
54,008 KB
testcase_39 AC 553 ms
53,896 KB
testcase_40 AC 26 ms
5,188 KB
testcase_41 AC 25 ms
5,228 KB
testcase_42 AC 24 ms
5,148 KB
testcase_43 AC 28 ms
5,184 KB
testcase_44 AC 21 ms
5,092 KB
testcase_45 WA -
testcase_46 AC 24 ms
5,088 KB
testcase_47 AC 24 ms
5,224 KB
testcase_48 AC 40 ms
6,464 KB
testcase_49 AC 29 ms
6,420 KB
testcase_50 AC 31 ms
6,428 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 824 ms
84,964 KB
testcase_53 AC 836 ms
84,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
map<ll, vector<ll>> mp;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<int> A(N), ans(N);
    vector<l_l> v(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        v[i] = {A[i], i};
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < (1 << N); i++) {
        ll sum = 0;
        for(int j = 0; j <= min(N, 30LL); j++) {
            if(i & (1 << j)) sum += v[j].first;
        }
        if(mp.count(sum)) {
            for(int j = 0; j <= min(N, 30LL); j++) {
                if(i & (1 << j)) ans[v[j].second] += v[j].first;
            }
            for(auto tmp : mp[sum]) {
                ans[tmp] -= A[tmp];
            }
            cout << "Yes" << endl;
            for(int i = 0; i < N; i++) {
                if(i != 0) cout << " ";
                cout << ans[i];
            }
            cout << endl;
            return 0;
        } else {
            for(int j = 0; j <= min(N, 30LL); j++) {
                if(i & (1 << j)) mp[sum].push_back(v[j].second);
            }
        }
    }
    cout << "No" << endl;
    return 0;
}
0