結果

問題 No.1017 Reiwa Sequence
コンテスト
ユーザー AEn
提出日時 2022-12-31 14:01:21
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 243 ms / 2,000 ms
+ 619µs
コード長 599 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 65 ms
コンパイル使用メモリ 81,520 KB
実行使用メモリ 219,016 KB
最終ジャッジ日時 2026-09-30 08:33:26
合計ジャッジ時間 26,544 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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