結果

問題 No.1017 Reiwa Sequence
ユーザー titiatitia
提出日時 2020-04-03 23:15:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,268 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 137,228 KB
最終ジャッジ日時 2023-09-16 04:39:16
合計ジャッジ時間 39,416 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,452 KB
testcase_01 AC 95 ms
71,816 KB
testcase_02 AC 95 ms
71,640 KB
testcase_03 AC 116 ms
77,720 KB
testcase_04 AC 96 ms
71,560 KB
testcase_05 AC 96 ms
71,640 KB
testcase_06 AC 96 ms
71,708 KB
testcase_07 AC 95 ms
71,664 KB
testcase_08 AC 93 ms
71,984 KB
testcase_09 AC 132 ms
77,984 KB
testcase_10 AC 179 ms
77,996 KB
testcase_11 AC 115 ms
77,676 KB
testcase_12 AC 140 ms
77,856 KB
testcase_13 AC 117 ms
77,792 KB
testcase_14 AC 147 ms
77,836 KB
testcase_15 AC 257 ms
77,848 KB
testcase_16 AC 152 ms
77,808 KB
testcase_17 AC 1,346 ms
77,608 KB
testcase_18 AC 150 ms
77,512 KB
testcase_19 AC 1,391 ms
77,824 KB
testcase_20 AC 1,392 ms
78,040 KB
testcase_21 AC 1,397 ms
77,828 KB
testcase_22 AC 1,406 ms
77,764 KB
testcase_23 AC 1,399 ms
77,820 KB
testcase_24 AC 1,393 ms
77,636 KB
testcase_25 AC 1,412 ms
77,636 KB
testcase_26 AC 1,419 ms
77,536 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 216 ms
77,824 KB
testcase_30 AC 723 ms
77,812 KB
testcase_31 AC 296 ms
77,880 KB
testcase_32 AC 286 ms
77,768 KB
testcase_33 AC 129 ms
77,548 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 522 ms
77,868 KB
testcase_39 WA -
testcase_40 AC 180 ms
114,500 KB
testcase_41 AC 182 ms
114,360 KB
testcase_42 AC 175 ms
111,028 KB
testcase_43 AC 177 ms
111,108 KB
testcase_44 AC 181 ms
114,128 KB
testcase_45 AC 181 ms
114,320 KB
testcase_46 AC 180 ms
111,144 KB
testcase_47 AC 177 ms
110,592 KB
testcase_48 WA -
testcase_49 AC 210 ms
137,228 KB
testcase_50 WA -
testcase_51 AC 99 ms
71,816 KB
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

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(14,N)
from itertools import product
ITER=product([-1,0,1],repeat=M)
SET=set(A[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
    
    if S in SET:
        ANS=[]
        for i in range(M):
            ANS.append(ite[i]*A[i])
        ANS+=[0]*abs(N-M)

        for i in range(N):
            if A[i]==S:
                ANS[i]=-S
                break
        print("Yes")
        print(*ANS)
        break
                     
else:
    print("No")
    

0