結果

問題 No.1017 Reiwa Sequence
ユーザー kyo1kyo1
提出日時 2020-06-19 03:54:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 902 bytes
コンパイル時間 2,784 ms
コンパイル使用メモリ 203,720 KB
実行使用メモリ 145,540 KB
最終ジャッジ日時 2023-09-16 12:36:21
合計ジャッジ時間 30,218 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
96,712 KB
testcase_01 AC 64 ms
96,776 KB
testcase_02 AC 54 ms
96,812 KB
testcase_03 AC 54 ms
96,848 KB
testcase_04 AC 55 ms
96,716 KB
testcase_05 AC 54 ms
96,980 KB
testcase_06 AC 50 ms
96,696 KB
testcase_07 AC 48 ms
96,760 KB
testcase_08 AC 47 ms
96,692 KB
testcase_09 AC 49 ms
96,888 KB
testcase_10 AC 169 ms
107,472 KB
testcase_11 AC 50 ms
96,756 KB
testcase_12 AC 978 ms
137,924 KB
testcase_13 AC 950 ms
137,512 KB
testcase_14 AC 59 ms
96,780 KB
testcase_15 AC 57 ms
96,788 KB
testcase_16 AC 56 ms
97,084 KB
testcase_17 AC 61 ms
97,292 KB
testcase_18 AC 58 ms
96,816 KB
testcase_19 AC 193 ms
113,060 KB
testcase_20 AC 203 ms
113,192 KB
testcase_21 AC 204 ms
113,060 KB
testcase_22 AC 211 ms
113,140 KB
testcase_23 AC 195 ms
113,064 KB
testcase_24 AC 191 ms
113,064 KB
testcase_25 AC 184 ms
113,372 KB
testcase_26 AC 175 ms
113,200 KB
testcase_27 AC 191 ms
113,128 KB
testcase_28 AC 182 ms
113,024 KB
testcase_29 AC 186 ms
112,804 KB
testcase_30 AC 183 ms
112,752 KB
testcase_31 AC 180 ms
112,064 KB
testcase_32 AC 175 ms
111,164 KB
testcase_33 AC 148 ms
108,916 KB
testcase_34 AC 175 ms
109,228 KB
testcase_35 AC 129 ms
109,092 KB
testcase_36 AC 160 ms
108,932 KB
testcase_37 AC 183 ms
111,020 KB
testcase_38 AC 163 ms
111,112 KB
testcase_39 AC 179 ms
111,084 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 AC 383 ms
116,696 KB
testcase_51 AC 59 ms
96,764 KB
testcase_52 AC 183 ms
112,996 KB
testcase_53 AC 167 ms
113,048 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 < N; j++) {
      if ((plus >> j) & 1) {
        cout << A[j];
      } else if ((minus >> j) & 1) {
        cout << -A[j];
      } else {
        cout << 0;
      }
      cout << (j == N - 1 ? '\n' : ' ');
    }
    return 0;
  }
  cout << "No" << '\n';
  return 0;
}
0