結果
問題 |
No.1017 Reiwa Sequence
|
ユーザー |
|
提出日時 | 2021-05-09 12:04:23 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 898 bytes |
コンパイル時間 | 479 ms |
コンパイル使用メモリ | 82,080 KB |
実行使用メモリ | 100,228 KB |
最終ジャッジ日時 | 2024-09-18 18:17:05 |
合計ジャッジ時間 | 35,218 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 4 |
other | RE * 50 |
ソースコード
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==val: index = get(vv) index.append(i) res.append(index) nd[v+vv] = i d.update(nd) if len(res)>=2: 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")