結果

問題 No.1017 Reiwa Sequence
ユーザー titiatitia
提出日時 2020-07-31 02:43:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 1,396 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 129,016 KB
最終ジャッジ日時 2023-09-18 15:04:36
合計ジャッジ時間 19,624 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
94,540 KB
testcase_01 AC 82 ms
94,484 KB
testcase_02 AC 83 ms
94,420 KB
testcase_03 AC 88 ms
99,328 KB
testcase_04 AC 84 ms
94,668 KB
testcase_05 AC 84 ms
94,484 KB
testcase_06 AC 85 ms
94,540 KB
testcase_07 AC 84 ms
94,440 KB
testcase_08 AC 83 ms
94,448 KB
testcase_09 AC 89 ms
99,916 KB
testcase_10 AC 91 ms
99,568 KB
testcase_11 AC 89 ms
99,636 KB
testcase_12 AC 93 ms
99,568 KB
testcase_13 AC 90 ms
99,740 KB
testcase_14 AC 92 ms
99,948 KB
testcase_15 AC 91 ms
99,532 KB
testcase_16 AC 90 ms
99,920 KB
testcase_17 AC 93 ms
99,524 KB
testcase_18 AC 91 ms
99,592 KB
testcase_19 AC 222 ms
100,000 KB
testcase_20 AC 226 ms
100,072 KB
testcase_21 AC 227 ms
99,928 KB
testcase_22 AC 225 ms
100,500 KB
testcase_23 AC 223 ms
99,976 KB
testcase_24 AC 224 ms
100,356 KB
testcase_25 AC 221 ms
99,932 KB
testcase_26 AC 206 ms
99,956 KB
testcase_27 AC 178 ms
99,972 KB
testcase_28 AC 190 ms
100,040 KB
testcase_29 AC 92 ms
99,544 KB
testcase_30 AC 98 ms
99,792 KB
testcase_31 AC 109 ms
99,692 KB
testcase_32 AC 153 ms
99,572 KB
testcase_33 AC 93 ms
99,688 KB
testcase_34 AC 160 ms
99,560 KB
testcase_35 AC 86 ms
94,488 KB
testcase_36 AC 88 ms
98,972 KB
testcase_37 AC 159 ms
99,916 KB
testcase_38 AC 87 ms
94,568 KB
testcase_39 AC 157 ms
99,916 KB
testcase_40 AC 327 ms
113,204 KB
testcase_41 AC 331 ms
113,200 KB
testcase_42 AC 329 ms
111,740 KB
testcase_43 AC 326 ms
111,464 KB
testcase_44 AC 119 ms
116,964 KB
testcase_45 AC 324 ms
113,056 KB
testcase_46 AC 315 ms
111,544 KB
testcase_47 AC 305 ms
111,672 KB
testcase_48 AC 143 ms
128,864 KB
testcase_49 AC 138 ms
128,436 KB
testcase_50 AC 138 ms
129,016 KB
testcase_51 AC 83 ms
94,592 KB
testcase_52 AC 206 ms
100,128 KB
testcase_53 AC 120 ms
99,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

if N>=22:
    X=[-1]*(150000*20+1)
    for i in range(1,1<<20):
        SUM=0
        for j in range(20):
            if (1<<j) & i !=0:
                SUM+=A[j]
        if X[SUM]==-1:
            X[SUM]=i
        else:
            print("Yes")
            ANS=[]
            k=X[SUM]
            l=i
            for j in range(20):
                if (1<<j) & k == 0 and (1<<j) & l != 0:
                    ANS.append(A[j])
                elif (1<<j) & k != 0 and (1<<j) & l == 0:
                    ANS.append(-A[j])
                else:
                    ANS.append(0)
            print(*(ANS+[0]*(N-20)))
            sys.exit()

else:
    X=[-1]*(150000*20+1)
    for i in range(1,1<<N):
        SUM=0
        for j in range(N):
            if (1<<j) & i !=0:
                SUM+=A[j]
        if X[SUM]==-1:
            X[SUM]=i
        else:
            print("Yes")
            ANS=[]
            k=X[SUM]
            l=i
            for j in range(N):
                if (1<<j) & k == 0 and (1<<j) & l != 0:
                    ANS.append(A[j])
                elif (1<<j) & k != 0 and (1<<j) & l == 0:
                    ANS.append(-A[j])
                else:
                    ANS.append(0)
            print(*ANS)
            sys.exit()
    print("No")
    
    

            
        
0