結果

問題 No.1017 Reiwa Sequence
ユーザー shotoyooshotoyoo
提出日時 2021-05-09 12:06:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,569 ms / 2,000 ms
コード長 981 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,612 KB
実行使用メモリ 345,784 KB
最終ジャッジ日時 2023-10-18 22:19:17
合計ジャッジ時間 49,949 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,344 KB
testcase_01 AC 40 ms
53,356 KB
testcase_02 AC 41 ms
53,356 KB
testcase_03 AC 40 ms
53,356 KB
testcase_04 AC 39 ms
53,356 KB
testcase_05 AC 40 ms
53,356 KB
testcase_06 AC 40 ms
53,356 KB
testcase_07 AC 40 ms
53,356 KB
testcase_08 AC 39 ms
53,356 KB
testcase_09 AC 44 ms
59,632 KB
testcase_10 AC 49 ms
61,864 KB
testcase_11 AC 44 ms
59,660 KB
testcase_12 AC 48 ms
61,864 KB
testcase_13 AC 39 ms
53,368 KB
testcase_14 AC 44 ms
59,660 KB
testcase_15 AC 44 ms
59,660 KB
testcase_16 AC 44 ms
59,660 KB
testcase_17 AC 47 ms
63,228 KB
testcase_18 AC 45 ms
59,660 KB
testcase_19 AC 288 ms
176,724 KB
testcase_20 AC 271 ms
176,728 KB
testcase_21 AC 281 ms
176,724 KB
testcase_22 AC 282 ms
176,736 KB
testcase_23 AC 274 ms
176,736 KB
testcase_24 AC 283 ms
176,736 KB
testcase_25 AC 277 ms
176,736 KB
testcase_26 AC 261 ms
176,736 KB
testcase_27 AC 325 ms
166,760 KB
testcase_28 AC 289 ms
176,752 KB
testcase_29 AC 57 ms
67,740 KB
testcase_30 AC 59 ms
71,496 KB
testcase_31 AC 113 ms
96,888 KB
testcase_32 AC 433 ms
168,712 KB
testcase_33 AC 56 ms
67,640 KB
testcase_34 AC 569 ms
200,516 KB
testcase_35 AC 39 ms
53,368 KB
testcase_36 AC 39 ms
53,368 KB
testcase_37 AC 413 ms
179,748 KB
testcase_38 AC 41 ms
53,368 KB
testcase_39 AC 429 ms
171,180 KB
testcase_40 AC 1,569 ms
342,296 KB
testcase_41 AC 1,501 ms
333,276 KB
testcase_42 AC 1,485 ms
330,768 KB
testcase_43 AC 1,536 ms
341,380 KB
testcase_44 AC 66 ms
84,620 KB
testcase_45 AC 1,414 ms
345,784 KB
testcase_46 AC 1,414 ms
332,852 KB
testcase_47 AC 1,289 ms
325,292 KB
testcase_48 AC 91 ms
100,092 KB
testcase_49 AC 80 ms
98,588 KB
testcase_50 AC 85 ms
99,592 KB
testcase_51 AC 40 ms
53,260 KB
testcase_52 AC 272 ms
176,672 KB
testcase_53 AC 154 ms
147,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n = int(input())
a = list(map(int, input().split()))
s = set([0])
done = 0
d = {0: None}
res = []
def get(v):
    assert v in d
    index = []
    while d[v] is not None:
        ind = d[v]
        index.append(ind)
        v -= a[ind]
    return index
for i,v in enumerate(a):
    nd = {}
    for vv in d:
        if v+vv in d:
            index0 = get(v+vv)
            index = get(vv)
            index.append(i)
            res.append(index)
            res.append(index0)
        nd[v+vv] = i
    d.update(nd)
    if len(res)>=2:
        print("Yes")
        ans = [0]*n
        for i in res[0]:
            ans[i] += a[i]
        for i in res[1]:
            ans[i] -= a[i]
        write(" ".join(map(str, ans)))
        break
else:
    print("No")
0