結果

問題 No.1017 Reiwa Sequence
ユーザー kyo1kyo1
提出日時 2020-06-19 04:04:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,097 ms / 2,000 ms
コード長 974 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 202,760 KB
実行使用メモリ 145,708 KB
最終ジャッジ日時 2023-09-16 12:39:05
合計ジャッジ時間 28,730 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
96,808 KB
testcase_01 AC 43 ms
96,836 KB
testcase_02 AC 36 ms
96,608 KB
testcase_03 AC 37 ms
96,692 KB
testcase_04 AC 36 ms
96,652 KB
testcase_05 AC 36 ms
96,908 KB
testcase_06 AC 37 ms
96,780 KB
testcase_07 AC 37 ms
96,712 KB
testcase_08 AC 35 ms
96,880 KB
testcase_09 AC 37 ms
96,812 KB
testcase_10 AC 175 ms
107,380 KB
testcase_11 AC 37 ms
96,796 KB
testcase_12 AC 1,029 ms
137,784 KB
testcase_13 AC 1,007 ms
137,540 KB
testcase_14 AC 44 ms
96,856 KB
testcase_15 AC 44 ms
96,740 KB
testcase_16 AC 44 ms
96,876 KB
testcase_17 AC 47 ms
97,272 KB
testcase_18 AC 43 ms
96,848 KB
testcase_19 AC 187 ms
113,144 KB
testcase_20 AC 200 ms
113,356 KB
testcase_21 AC 197 ms
113,092 KB
testcase_22 AC 203 ms
113,228 KB
testcase_23 AC 194 ms
113,292 KB
testcase_24 AC 191 ms
113,288 KB
testcase_25 AC 183 ms
113,180 KB
testcase_26 AC 168 ms
113,260 KB
testcase_27 AC 190 ms
113,052 KB
testcase_28 AC 181 ms
113,260 KB
testcase_29 AC 186 ms
112,920 KB
testcase_30 AC 185 ms
112,872 KB
testcase_31 AC 183 ms
112,128 KB
testcase_32 AC 172 ms
111,312 KB
testcase_33 AC 150 ms
109,116 KB
testcase_34 AC 175 ms
108,964 KB
testcase_35 AC 122 ms
108,936 KB
testcase_36 AC 158 ms
109,024 KB
testcase_37 AC 185 ms
111,076 KB
testcase_38 AC 161 ms
111,068 KB
testcase_39 AC 178 ms
111,036 KB
testcase_40 AC 1,097 ms
144,396 KB
testcase_41 AC 1,062 ms
143,852 KB
testcase_42 AC 1,088 ms
145,708 KB
testcase_43 AC 1,070 ms
144,264 KB
testcase_44 AC 418 ms
117,876 KB
testcase_45 AC 1,027 ms
142,396 KB
testcase_46 AC 960 ms
142,332 KB
testcase_47 AC 817 ms
139,308 KB
testcase_48 AC 1,009 ms
136,252 KB
testcase_49 AC 422 ms
115,672 KB
testcase_50 AC 420 ms
116,868 KB
testcase_51 AC 44 ms
96,844 KB
testcase_52 AC 180 ms
113,276 KB
testcase_53 AC 164 ms
113,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int M = min(N, 22);
  vector<vector<int>> masks(4000000);
  for (int mask = 0; mask < (1 << M); mask++) {
    int sum = 0;
    for (int i = 0; i < M; i++) {
      if ((mask >> i) & 1) sum += A[i];
    }
    masks[sum].emplace_back(mask);
  }
  for (int i = 1; i < (int)masks.size(); i++) {
    if ((int)masks[i].size() < 2) continue;
    int plus = masks[i][0], minus = masks[i][1];
    cout << "Yes" << '\n';
    for (int j = 0; j < M; j++) {
      if (j != 0) cout << ' ';
      if ((plus >> j) & 1) {
        cout << A[j];
      } else if ((minus >> j) & 1) {
        cout << -A[j];
      } else {
        cout << 0;
      }
    }
    for (int j = M; j < N; j++) {
      cout << ' ' << 0;
    }
    cout << '\n';
    return 0;
  }
  cout << "No" << '\n';
  return 0;
}
0