結果

問題 No.1017 Reiwa Sequence
ユーザー tochiji1tochiji1
提出日時 2020-04-12 00:19:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,067 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 1,683 ms
コンパイル使用メモリ 171,956 KB
実行使用メモリ 129,424 KB
最終ジャッジ日時 2023-09-16 07:13:20
合計ジャッジ時間 26,971 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
20,796 KB
testcase_01 AC 8 ms
13,664 KB
testcase_02 AC 5 ms
10,092 KB
testcase_03 AC 17 ms
34,732 KB
testcase_04 AC 7 ms
10,156 KB
testcase_05 AC 8 ms
17,112 KB
testcase_06 AC 7 ms
13,716 KB
testcase_07 AC 6 ms
10,008 KB
testcase_08 AC 6 ms
10,084 KB
testcase_09 AC 22 ms
45,316 KB
testcase_10 AC 153 ms
80,720 KB
testcase_11 AC 21 ms
41,748 KB
testcase_12 AC 966 ms
121,396 KB
testcase_13 AC 938 ms
121,292 KB
testcase_14 AC 24 ms
41,744 KB
testcase_15 AC 27 ms
45,160 KB
testcase_16 AC 25 ms
41,644 KB
testcase_17 AC 35 ms
52,756 KB
testcase_18 AC 25 ms
41,820 KB
testcase_19 AC 206 ms
86,052 KB
testcase_20 AC 217 ms
86,208 KB
testcase_21 AC 217 ms
86,212 KB
testcase_22 AC 225 ms
86,236 KB
testcase_23 AC 209 ms
86,176 KB
testcase_24 AC 205 ms
86,432 KB
testcase_25 AC 193 ms
86,124 KB
testcase_26 AC 186 ms
86,152 KB
testcase_27 AC 175 ms
86,324 KB
testcase_28 AC 160 ms
86,144 KB
testcase_29 AC 171 ms
85,936 KB
testcase_30 AC 165 ms
85,832 KB
testcase_31 AC 164 ms
85,272 KB
testcase_32 AC 160 ms
84,420 KB
testcase_33 AC 138 ms
82,476 KB
testcase_34 AC 157 ms
82,240 KB
testcase_35 AC 113 ms
82,240 KB
testcase_36 AC 143 ms
82,252 KB
testcase_37 AC 162 ms
84,160 KB
testcase_38 AC 148 ms
84,364 KB
testcase_39 AC 163 ms
84,224 KB
testcase_40 AC 1,054 ms
128,084 KB
testcase_41 AC 1,014 ms
127,320 KB
testcase_42 AC 1,067 ms
129,424 KB
testcase_43 AC 1,038 ms
128,000 KB
testcase_44 AC 380 ms
101,648 KB
testcase_45 AC 981 ms
126,160 KB
testcase_46 AC 927 ms
125,928 KB
testcase_47 AC 771 ms
123,088 KB
testcase_48 AC 961 ms
119,972 KB
testcase_49 AC 397 ms
99,380 KB
testcase_50 AC 402 ms
100,536 KB
testcase_51 AC 4 ms
6,788 KB
testcase_52 AC 172 ms
86,164 KB
testcase_53 AC 157 ms
86,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int C = min(N,22);
    vector<vector<int>> sum(C*150000,vector<int>());

    rep(b,1<<C){
        int tmpsum = 0;
        rep(i,C) if(b&(1<<i)) tmpsum += A[i];
        sum[tmpsum].push_back(b);
    }

    int minSum = C;
    for(auto e:sum) {
        if(e.size() >= 2) {
            cout << "Yes" << endl;
            int b0 = e[0];
            int b1 = e[1];
            rep(i,N){
                if(i>=C) {
                    cout << 0 << " ";
                    continue;
                }
                if(b0&(1<<i)) cout << A[i] << " ";
                else if(b1&(1<<i)) cout << -1*A[i] << " ";
                else cout << 0 << " ";
            }
            cout << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}
0