結果

問題 No.1017 Reiwa Sequence
ユーザー ayaoni
提出日時 2020-11-26 13:55:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 82,184 KB
実行使用メモリ 131,692 KB
最終ジャッジ日時 2024-07-23 20:47:01
合計ジャッジ時間 39,137 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))


N = I()
A = LI()[:22]
M = len(A)

flag = [None]*3300001
ans = [0]*M
for i in range(1<<M):
    x = 0
    for j in range(M):
        if (i>>j) & 1:
            x += A[j]
    if flag[x]:
        print('Yes')
        for j in range(M):
            ans[j] = (((i>>j) & 1)-((flag[x]>>j) & 1))*A[j]
        break
    else:
        flag[x] = i
else:
    print('No')
    exit()

ans += [0]*(N-M)
print(*ans)
0