結果

問題 No.1017 Reiwa Sequence
ユーザー 👑 SPD_9X2
提出日時 2025-07-16 01:20:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 830 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 288,196 KB
最終ジャッジ日時 2025-07-16 01:20:49
合計ジャッジ時間 38,766 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/1017

300000ペア以上あれば、必ず衝突する

長さ600以下の場合、ちゃんと考えないとダメか?
dpして復元かなぁ...
しかし、A[i]が大きい場合に苦しい

3つ、4つと増やしていけばいいか
重複はない

最初の22項だけ取ればいいのか

"""

import sys

N = int(input())

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

dic = {}

def check( pos ):
    s = 0
    for p in pos:
        s += A[p]
    if s in dic:
        ans = [0] * N
        for p in dic[s]:
            ans[p] = -1 * A[p]
        for p in pos:
            ans[p] = 1 * A[p]

        print ("Yes")
        print (*ans)
        sys.exit()

    dic[s] = pos


MM = min(N,22)
for bit in range(2**MM):
    pos = []
    for i in range(MM):
        if (2**i) & bit:
            pos.append(i)
    check( tuple(pos) )

print ("No")

0