結果

問題 No.1017 Reiwa Sequence
ユーザー AEn
提出日時 2022-12-31 14:01:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 403 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 213,392 KB
最終ジャッジ日時 2024-11-26 11:44:41
合計ジャッジ時間 39,421 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

n = min(22,N)
s = set()
d = {}
for i in range(1,1<<n):
    sm = 0
    for j in range(n):
        if i&(1<<j):
            sm += A[j]
    if sm in s:
        bit1,bit2 = d[sm],i
        res = [0]*N
        for k in range(n):
            if bit1&(1<<k) and not bit2&(1<<k):
                res[k] = 1
            elif bit2&(1<<k) and not bit1&(1<<k):
                res[k] = -1
        for k in range(N):
            res[k] *= A[k]
        print('Yes')
        print(*res)
        exit()
    else:
        s.add(sm)
        d[sm] = i

print('No')
0