結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
96,860 KB
testcase_01 AC 47 ms
96,904 KB
testcase_02 AC 35 ms
96,744 KB
testcase_03 AC 36 ms
96,772 KB
testcase_04 AC 36 ms
97,048 KB
testcase_05 AC 36 ms
96,932 KB
testcase_06 AC 37 ms
96,608 KB
testcase_07 AC 36 ms
96,708 KB
testcase_08 AC 35 ms
96,852 KB
testcase_09 AC 37 ms
96,808 KB
testcase_10 AC 165 ms
107,312 KB
testcase_11 AC 38 ms
97,008 KB
testcase_12 AC 1,015 ms
137,892 KB
testcase_13 AC 990 ms
137,576 KB
testcase_14 AC 47 ms
96,724 KB
testcase_15 AC 48 ms
96,844 KB
testcase_16 AC 48 ms
96,764 KB
testcase_17 AC 50 ms
97,420 KB
testcase_18 AC 48 ms
96,760 KB
testcase_19 AC 185 ms
113,176 KB
testcase_20 AC 196 ms
113,220 KB
testcase_21 AC 192 ms
113,152 KB
testcase_22 AC 198 ms
113,036 KB
testcase_23 AC 184 ms
113,288 KB
testcase_24 AC 190 ms
113,232 KB
testcase_25 AC 175 ms
113,004 KB
testcase_26 AC 168 ms
113,148 KB
testcase_27 AC 184 ms
113,216 KB
testcase_28 AC 170 ms
113,028 KB
testcase_29 AC 183 ms
112,824 KB
testcase_30 AC 178 ms
112,688 KB
testcase_31 AC 176 ms
112,088 KB
testcase_32 AC 164 ms
111,160 KB
testcase_33 AC 152 ms
109,004 KB
testcase_34 AC 166 ms
108,832 KB
testcase_35 AC 117 ms
109,068 KB
testcase_36 AC 158 ms
109,052 KB
testcase_37 AC 178 ms
111,052 KB
testcase_38 AC 160 ms
110,980 KB
testcase_39 AC 179 ms
111,064 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 362 ms
116,812 KB
testcase_51 AC 49 ms
96,612 KB
testcase_52 AC 172 ms
113,128 KB
testcase_53 AC 159 ms
113,148 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 = 1; 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 = 0; 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