結果

問題 No.1017 Reiwa Sequence
ユーザー QCFiumQCFium
提出日時 2020-04-03 22:11:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 1,521 ms
コンパイル使用メモリ 164,684 KB
実行使用メモリ 29,896 KB
最終ジャッジ日時 2023-09-16 02:08:43
合計ジャッジ時間 13,728 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
29,248 KB
testcase_01 AC 9 ms
29,236 KB
testcase_02 AC 9 ms
29,272 KB
testcase_03 AC 10 ms
29,252 KB
testcase_04 AC 9 ms
29,244 KB
testcase_05 AC 9 ms
29,316 KB
testcase_06 AC 9 ms
29,292 KB
testcase_07 AC 10 ms
29,212 KB
testcase_08 AC 9 ms
29,324 KB
testcase_09 AC 9 ms
29,384 KB
testcase_10 AC 9 ms
29,252 KB
testcase_11 AC 10 ms
29,280 KB
testcase_12 AC 10 ms
29,236 KB
testcase_13 AC 10 ms
29,228 KB
testcase_14 AC 9 ms
29,168 KB
testcase_15 AC 10 ms
29,148 KB
testcase_16 AC 10 ms
29,156 KB
testcase_17 AC 10 ms
29,148 KB
testcase_18 AC 10 ms
29,204 KB
testcase_19 AC 44 ms
29,380 KB
testcase_20 AC 44 ms
29,252 KB
testcase_21 AC 44 ms
29,224 KB
testcase_22 AC 43 ms
29,248 KB
testcase_23 AC 43 ms
29,228 KB
testcase_24 AC 42 ms
29,228 KB
testcase_25 AC 42 ms
29,352 KB
testcase_26 AC 42 ms
29,452 KB
testcase_27 AC 32 ms
29,472 KB
testcase_28 AC 34 ms
29,240 KB
testcase_29 AC 10 ms
29,368 KB
testcase_30 AC 12 ms
29,244 KB
testcase_31 AC 14 ms
29,388 KB
testcase_32 AC 27 ms
29,300 KB
testcase_33 AC 10 ms
29,248 KB
testcase_34 AC 26 ms
29,316 KB
testcase_35 AC 10 ms
29,380 KB
testcase_36 AC 9 ms
29,312 KB
testcase_37 AC 27 ms
29,368 KB
testcase_38 AC 9 ms
29,316 KB
testcase_39 AC 26 ms
29,256 KB
testcase_40 AC 59 ms
29,680 KB
testcase_41 AC 59 ms
29,740 KB
testcase_42 AC 58 ms
29,576 KB
testcase_43 AC 58 ms
29,588 KB
testcase_44 AC 22 ms
29,808 KB
testcase_45 AC 59 ms
29,588 KB
testcase_46 AC 58 ms
29,576 KB
testcase_47 AC 58 ms
29,588 KB
testcase_48 AC 30 ms
29,896 KB
testcase_49 AC 30 ms
29,824 KB
testcase_50 AC 31 ms
29,892 KB
testcase_51 AC 9 ms
29,176 KB
testcase_52 AC 42 ms
29,228 KB
testcase_53 AC 18 ms
29,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	int x = std::min(n, 22);
	static int used[22 * 150000 * 2 + 1];
	for (auto &i : used) i = -1;
	for (int i = 1; i < 1 << x; i++) {
		int cur = 0;
		for (int j = 0; j < x; j++) if (i >> j & 1) cur += a[j];
		if (used[cur + 22 * 150000] != -1) {
			puts("Yes");
			for (int j = 0; j < n; j++) {
				if (j < x) printf("%d ", a[j] * ((i >> j & 1) - (used[cur + 22 * 150000] >> j & 1)));
				else printf("0 ");
			}
			puts("");
			return 0;
		}
		used[cur + 22 * 150000] = i;
	}
	puts("No");
	return 0;
}
0