結果

問題 No.1017 Reiwa Sequence
ユーザー MayimgMayimg
提出日時 2020-04-06 00:41:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,039 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 202,592 KB
実行使用メモリ 129,372 KB
最終ジャッジ日時 2023-09-16 06:51:48
合計ジャッジ時間 34,113 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
80,712 KB
testcase_01 RE -
testcase_02 AC 33 ms
80,772 KB
testcase_03 AC 34 ms
80,848 KB
testcase_04 AC 33 ms
80,776 KB
testcase_05 AC 33 ms
80,712 KB
testcase_06 AC 34 ms
80,712 KB
testcase_07 AC 34 ms
80,712 KB
testcase_08 AC 34 ms
80,704 KB
testcase_09 AC 34 ms
80,840 KB
testcase_10 AC 172 ms
91,564 KB
testcase_11 AC 35 ms
80,768 KB
testcase_12 AC 1,065 ms
121,908 KB
testcase_13 AC 1,056 ms
121,528 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 186 ms
97,076 KB
testcase_28 AC 183 ms
97,076 KB
testcase_29 AC 187 ms
96,976 KB
testcase_30 AC 181 ms
96,724 KB
testcase_31 AC 181 ms
96,016 KB
testcase_32 AC 173 ms
95,172 KB
testcase_33 AC 157 ms
93,096 KB
testcase_34 AC 172 ms
93,060 KB
testcase_35 AC 124 ms
92,996 KB
testcase_36 AC 162 ms
93,004 KB
testcase_37 AC 182 ms
95,044 KB
testcase_38 AC 161 ms
95,232 KB
testcase_39 AC 177 ms
95,036 KB
testcase_40 AC 1,119 ms
128,088 KB
testcase_41 AC 1,064 ms
127,284 KB
testcase_42 AC 1,091 ms
129,372 KB
testcase_43 AC 1,077 ms
128,268 KB
testcase_44 AC 350 ms
101,304 KB
testcase_45 AC 1,015 ms
126,128 KB
testcase_46 AC 974 ms
125,936 KB
testcase_47 AC 828 ms
123,156 KB
testcase_48 AC 1,028 ms
119,604 KB
testcase_49 AC 350 ms
98,824 KB
testcase_50 AC 355 ms
100,788 KB
testcase_51 RE -
testcase_52 AC 188 ms
97,152 KB
testcase_53 AC 160 ms
97,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
vector<int> sum[3300003];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int m = min(22, n);
  vector<int> a(m);
  for (int i = 0; i < m; i++) cin >> a[i];
  for (int mask = 0; mask < (1 << m); mask++) {
    int s = 0;
    for (int i = 0; i < m; i++) if (mask & (1 << i)) s += a[i];
    sum[s].push_back(mask);
  }
  vector<int> ans(m);
  bool found = false;
  for (int t = 0; t <= 3300003; t++) {
    if ((int) sum[t].size() > 1) {
      for (int i = 0; i < m; i++) if (sum[t][0] & (1 << i)) ans[i] = 1;
      for (int i = 0; i < m; i++) if (sum[t][1] & (1 << i)) {
        if (ans[i] == 1) ans[i] = 0;
        else ans[i] = -1;
      }
      found = true;
      break;
    }
  }
  if (!found) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  for (int i = 0; i < m; i++) {
    if (i > 0) cout << " ";
    cout << ans[i] * a[i];
  }
  for (int i = m; i < n; i++) {
    cout << " " << 0;
  }
  cout << endl;
  return 0;
}
0