結果

問題 No.1017 Reiwa Sequence
ユーザー kyo1kyo1
提出日時 2020-06-19 04:02:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,002 bytes
コンパイル時間 2,128 ms
コンパイル使用メモリ 203,960 KB
実行使用メモリ 145,712 KB
最終ジャッジ日時 2023-09-16 12:37:40
合計ジャッジ時間 28,929 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
96,920 KB
testcase_01 AC 43 ms
96,844 KB
testcase_02 AC 36 ms
96,716 KB
testcase_03 AC 35 ms
96,844 KB
testcase_04 AC 36 ms
96,824 KB
testcase_05 AC 35 ms
96,856 KB
testcase_06 AC 35 ms
96,884 KB
testcase_07 AC 35 ms
96,848 KB
testcase_08 AC 36 ms
96,892 KB
testcase_09 AC 37 ms
96,828 KB
testcase_10 AC 172 ms
107,532 KB
testcase_11 AC 37 ms
96,788 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 44 ms
96,828 KB
testcase_15 AC 45 ms
96,880 KB
testcase_16 AC 44 ms
96,892 KB
testcase_17 AC 48 ms
97,408 KB
testcase_18 AC 45 ms
96,748 KB
testcase_19 AC 192 ms
113,216 KB
testcase_20 AC 207 ms
113,172 KB
testcase_21 AC 199 ms
113,124 KB
testcase_22 AC 210 ms
113,212 KB
testcase_23 AC 193 ms
113,216 KB
testcase_24 AC 192 ms
113,416 KB
testcase_25 AC 187 ms
113,296 KB
testcase_26 AC 169 ms
113,164 KB
testcase_27 AC 188 ms
113,200 KB
testcase_28 AC 181 ms
113,292 KB
testcase_29 AC 191 ms
112,928 KB
testcase_30 AC 188 ms
112,768 KB
testcase_31 AC 187 ms
112,200 KB
testcase_32 AC 177 ms
111,012 KB
testcase_33 AC 154 ms
108,992 KB
testcase_34 AC 177 ms
109,072 KB
testcase_35 AC 123 ms
108,892 KB
testcase_36 AC 159 ms
108,980 KB
testcase_37 AC 183 ms
111,080 KB
testcase_38 AC 159 ms
111,224 KB
testcase_39 AC 176 ms
111,304 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 45 ms
96,976 KB
testcase_52 AC 187 ms
113,124 KB
testcase_53 AC 166 ms
113,260 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++) {
      if (j != N - 1) cout << ' ';
      cout << 0;
    }
    cout << '\n';
    return 0;
  }
  cout << "No" << '\n';
  return 0;
}
0