結果

問題 No.1017 Reiwa Sequence
ユーザー ntudantuda
提出日時 2021-11-09 20:44:27
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 388 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 245,572 KB
最終ジャッジ日時 2023-08-12 04:34:56
合計ジャッジ時間 27,973 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
77,068 KB
testcase_01 AC 72 ms
74,880 KB
testcase_02 AC 72 ms
73,808 KB
testcase_03 AC 74 ms
81,768 KB
testcase_04 AC 70 ms
73,924 KB
testcase_05 AC 70 ms
76,040 KB
testcase_06 AC 71 ms
74,772 KB
testcase_07 AC 73 ms
73,728 KB
testcase_08 AC 71 ms
73,824 KB
testcase_09 AC 79 ms
90,532 KB
testcase_10 AC 85 ms
98,576 KB
testcase_11 AC 82 ms
89,156 KB
testcase_12 AC 83 ms
102,176 KB
testcase_13 AC 80 ms
96,848 KB
testcase_14 AC 80 ms
89,156 KB
testcase_15 AC 79 ms
90,384 KB
testcase_16 AC 79 ms
89,224 KB
testcase_17 AC 86 ms
95,888 KB
testcase_18 AC 82 ms
89,208 KB
testcase_19 AC 344 ms
230,352 KB
testcase_20 AC 341 ms
230,404 KB
testcase_21 AC 335 ms
230,164 KB
testcase_22 AC 343 ms
230,292 KB
testcase_23 AC 331 ms
230,540 KB
testcase_24 AC 337 ms
230,184 KB
testcase_25 AC 321 ms
230,160 KB
testcase_26 AC 309 ms
230,348 KB
testcase_27 AC 241 ms
165,680 KB
testcase_28 AC 255 ms
176,376 KB
testcase_29 AC 88 ms
99,404 KB
testcase_30 AC 92 ms
102,572 KB
testcase_31 AC 109 ms
118,812 KB
testcase_32 AC 210 ms
163,328 KB
testcase_33 AC 87 ms
98,940 KB
testcase_34 AC 225 ms
163,344 KB
testcase_35 AC 80 ms
93,644 KB
testcase_36 AC 80 ms
93,328 KB
testcase_37 AC 218 ms
163,504 KB
testcase_38 AC 82 ms
93,528 KB
testcase_39 AC 213 ms
163,288 KB
testcase_40 AC 386 ms
245,120 KB
testcase_41 AC 388 ms
245,124 KB
testcase_42 AC 363 ms
245,572 KB
testcase_43 AC 381 ms
245,164 KB
testcase_44 AC 117 ms
118,816 KB
testcase_45 AC 377 ms
245,300 KB
testcase_46 AC 356 ms
245,520 KB
testcase_47 AC 341 ms
245,348 KB
testcase_48 AC 141 ms
129,480 KB
testcase_49 AC 137 ms
129,444 KB
testcase_50 AC 135 ms
129,824 KB
testcase_51 AC 69 ms
72,776 KB
testcase_52 AC 268 ms
192,208 KB
testcase_53 AC 137 ms
139,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def calc():
    global M
    dp = [0] * (M * 150000)

    Smax = 1
    dic1 = {0:(0,)}
    dic2 = {}
    flag = 1
    for i in range(M):
        for k,v in dic1.items():
            if k+A[i] in dic2:
                for x in v:
                    dic2[k+A[i]] = dic2[k+A[i]] + tuple([x | 1 << i])
                if len(dic2[k+A[i]]) == 2:
                    return dic2[k+A[i]]
            else:
                for x in v:
                    dic2[k+A[i]] = tuple([x | 1 << i])
        dic1.update(dic2)
    return False

x = calc()
if x == False:
    print("No")
else:
    a,b = x
    k = 1
    for i in range(M):
        if (a | b) & k:
            if a & b & k:
                A[i] = 0
            elif b & k:
                A[i] = -A[i]
        else:
            A[i] = 0
        k <<= 1
    if N > M:
        for i in range(M,N):
            A[i] = 0
    print("Yes")
    print(*A)
0