結果
問題 | No.1826 Fruits Collecting |
ユーザー | mkawa2 |
提出日時 | 2022-01-29 12:37:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,220 ms / 2,000 ms |
コード長 | 1,587 bytes |
コンパイル時間 | 1,764 ms |
コンパイル使用メモリ | 87,196 KB |
実行使用メモリ | 168,132 KB |
最終ジャッジ日時 | 2023-08-30 10:12:50 |
合計ジャッジ時間 | 33,285 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 83 ms
76,260 KB |
testcase_01 | AC | 114 ms
78,108 KB |
testcase_02 | AC | 113 ms
78,220 KB |
testcase_03 | AC | 117 ms
78,108 KB |
testcase_04 | AC | 86 ms
76,148 KB |
testcase_05 | AC | 517 ms
114,584 KB |
testcase_06 | AC | 806 ms
143,884 KB |
testcase_07 | AC | 596 ms
124,204 KB |
testcase_08 | AC | 164 ms
80,820 KB |
testcase_09 | AC | 787 ms
143,372 KB |
testcase_10 | AC | 543 ms
120,312 KB |
testcase_11 | AC | 532 ms
109,356 KB |
testcase_12 | AC | 267 ms
91,928 KB |
testcase_13 | AC | 191 ms
83,736 KB |
testcase_14 | AC | 239 ms
89,120 KB |
testcase_15 | AC | 1,194 ms
167,668 KB |
testcase_16 | AC | 1,191 ms
164,252 KB |
testcase_17 | AC | 1,194 ms
167,960 KB |
testcase_18 | AC | 1,204 ms
167,648 KB |
testcase_19 | AC | 1,220 ms
167,636 KB |
testcase_20 | AC | 1,199 ms
167,884 KB |
testcase_21 | AC | 1,197 ms
164,408 KB |
testcase_22 | AC | 1,201 ms
164,380 KB |
testcase_23 | AC | 1,203 ms
168,132 KB |
testcase_24 | AC | 1,199 ms
164,780 KB |
testcase_25 | AC | 71 ms
71,460 KB |
testcase_26 | AC | 70 ms
71,052 KB |
testcase_27 | AC | 71 ms
71,068 KB |
testcase_28 | AC | 71 ms
71,052 KB |
testcase_29 | AC | 72 ms
71,408 KB |
testcase_30 | AC | 346 ms
95,596 KB |
testcase_31 | AC | 602 ms
120,100 KB |
testcase_32 | AC | 306 ms
95,948 KB |
testcase_33 | AC | 855 ms
144,324 KB |
testcase_34 | AC | 715 ms
135,780 KB |
testcase_35 | AC | 228 ms
89,512 KB |
testcase_36 | AC | 845 ms
144,116 KB |
testcase_37 | AC | 588 ms
116,524 KB |
testcase_38 | AC | 435 ms
114,920 KB |
testcase_39 | AC | 313 ms
120,192 KB |
testcase_40 | AC | 381 ms
131,724 KB |
testcase_41 | AC | 160 ms
87,012 KB |
testcase_42 | AC | 109 ms
78,532 KB |
testcase_43 | AC | 70 ms
71,228 KB |
testcase_44 | AC | 70 ms
71,472 KB |
testcase_45 | AC | 70 ms
71,476 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 18446744073709551615 # inf = 4294967295 # md = 10**9+7 md = 998244353 class Bit: def __init__(self, op, e, n): self.op = op self.e = e self.n = n+1 self.table = [e() for _ in range(self.n)] def update(self, i, x): i += 1 while i < self.n: self.table[i] = self.op(self.table[i], x) i += i & -i # [0,i] def prod(self, i): i += 1 res = self.e() while i > 0: res = self.op(res, self.table[i]) i -= i & -i return res n = II() txv = LLI(n) st = set() st.add(0) for t, x, v in txv: st.add(t-x) enc = {a: i for i, a in enumerate(sorted(st))} txv.sort(key=lambda x: (x[0]+x[1], x[0]-x[1])) bit = Bit(max, lambda: -inf, n+5) i = enc[0] bit.update(i, 0) for t, x, v in txv: if t+x < 0: continue i = enc[t-x] cur = bit.prod(i)+v bit.update(i, cur) print(bit.prod(n+4))