結果

問題 No.777 再帰的ケーキ
ユーザー mkawa2mkawa2
提出日時 2021-02-11 09:34:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,198 ms / 2,000 ms
コード長 1,480 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 86,608 KB
実行使用メモリ 171,444 KB
最終ジャッジ日時 2023-09-24 22:31:03
合計ジャッジ時間 13,177 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
72,900 KB
testcase_01 AC 71 ms
72,844 KB
testcase_02 AC 70 ms
72,864 KB
testcase_03 AC 70 ms
72,524 KB
testcase_04 AC 70 ms
72,704 KB
testcase_05 AC 70 ms
72,996 KB
testcase_06 AC 71 ms
72,996 KB
testcase_07 AC 73 ms
72,820 KB
testcase_08 AC 70 ms
72,824 KB
testcase_09 AC 71 ms
72,964 KB
testcase_10 AC 71 ms
72,996 KB
testcase_11 AC 71 ms
72,784 KB
testcase_12 AC 72 ms
72,924 KB
testcase_13 AC 73 ms
72,528 KB
testcase_14 AC 72 ms
72,524 KB
testcase_15 AC 71 ms
72,520 KB
testcase_16 AC 72 ms
72,656 KB
testcase_17 AC 72 ms
72,700 KB
testcase_18 AC 71 ms
73,028 KB
testcase_19 AC 71 ms
72,860 KB
testcase_20 AC 70 ms
72,968 KB
testcase_21 AC 110 ms
79,512 KB
testcase_22 AC 104 ms
79,492 KB
testcase_23 AC 91 ms
78,496 KB
testcase_24 AC 90 ms
78,288 KB
testcase_25 AC 108 ms
79,560 KB
testcase_26 AC 110 ms
79,476 KB
testcase_27 AC 92 ms
78,436 KB
testcase_28 AC 1,176 ms
151,912 KB
testcase_29 AC 1,162 ms
151,064 KB
testcase_30 AC 1,170 ms
163,164 KB
testcase_31 AC 1,198 ms
163,116 KB
testcase_32 AC 346 ms
171,444 KB
testcase_33 AC 219 ms
100,192 KB
testcase_34 AC 284 ms
110,624 KB
testcase_35 AC 989 ms
132,944 KB
testcase_36 AC 350 ms
171,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [[(-1, 0), (1, 0)], [(0, -1), (0, 1)]]
inf = 10**16
# md = 998244353
# md = 10**9+7

class BitMax:
    def __init__(self, n):
        self.inf = 10**9
        self.n = n+3
        self.table = [-self.inf]*(self.n+1)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            if x > self.table[i]: self.table[i] = x
            i += i & -i

    def max(self, i):
        i += 1
        res = -self.inf
        while i > 0:
            if self.table[i] > res: res = self.table[i]
            i -= i & -i
        return res

mx = 200005
n = II()
abc = LLI(n)

abc.sort(key=lambda x: (x[0], -x[1]))
enc = {x: i+1 for i, x in enumerate(sorted(set(b for a, b, c in abc)))}
bit = BitMax(mx)
bit.update(0, 0)
for a, b, c in abc:
    b = enc[b]
    cur = bit.max(b-1)+c
    bit.update(b, cur)
print(bit.max(mx-1))
0