結果

問題 No.1017 Reiwa Sequence
ユーザー titia
提出日時 2020-04-03 23:10:09
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 950 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 83,676 KB
最終ジャッジ日時 2024-07-03 05:49:51
合計ジャッジ時間 19,423 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15 TLE * 1 -- * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
A=[abs(a) for a in A]

from collections import Counter
C=Counter(A)

x=0
for c in C:
    if C[c]>1:
        x=c
        break

if x!=0:
    flag=0

    ANS=[]
    for a in A:
        if a!=x or flag==2:
            ANS.append(a)
        else:
            if flag==0:
                ANS.append(x)
                flag+=1
            elif flag==1:
                ANS.append(-x)
                flag+=1
                
    print("Yes")
    print(*ANS)
    sys.exit()


M=min(15,N)
from itertools import product
ITER=product([-1,0,1],repeat=M)

for ite in ITER:
    if max(ite)==min(ite)==0:
        continue
    S=0
    for i in range(M):
        S+=A[i]*ite[i]

    if S==0:
        ANS=[]
        for i in range(M):
            ANS.append(ite[i]*A[i])
        ANS+=[0]*abs(N-M)
        print("Yes")
        print(*ANS)
        break
else:
    print("No")
    

0