結果

問題 No.777 再帰的ケーキ
ユーザー torikuminotorikumino
提出日時 2019-01-11 22:19:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,984 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 138,720 KB
最終ジャッジ日時 2023-08-20 07:39:41
合計ジャッジ時間 14,157 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,648 KB
testcase_01 AC 72 ms
71,380 KB
testcase_02 AC 77 ms
71,436 KB
testcase_03 AC 72 ms
71,284 KB
testcase_04 AC 74 ms
71,172 KB
testcase_05 AC 74 ms
71,440 KB
testcase_06 AC 75 ms
71,092 KB
testcase_07 AC 75 ms
71,464 KB
testcase_08 AC 72 ms
71,484 KB
testcase_09 AC 72 ms
71,316 KB
testcase_10 AC 72 ms
71,096 KB
testcase_11 AC 72 ms
71,412 KB
testcase_12 AC 81 ms
71,380 KB
testcase_13 AC 83 ms
71,172 KB
testcase_14 AC 87 ms
71,180 KB
testcase_15 AC 84 ms
71,464 KB
testcase_16 AC 82 ms
71,376 KB
testcase_17 AC 81 ms
71,552 KB
testcase_18 AC 82 ms
71,412 KB
testcase_19 AC 75 ms
71,380 KB
testcase_20 AC 78 ms
71,436 KB
testcase_21 AC 155 ms
78,864 KB
testcase_22 AC 165 ms
79,024 KB
testcase_23 AC 132 ms
78,224 KB
testcase_24 AC 131 ms
78,308 KB
testcase_25 AC 155 ms
78,888 KB
testcase_26 AC 147 ms
78,992 KB
testcase_27 AC 126 ms
78,428 KB
testcase_28 AC 1,984 ms
138,720 KB
testcase_29 AC 1,862 ms
138,376 KB
testcase_30 AC 1,905 ms
137,524 KB
testcase_31 AC 1,872 ms
137,336 KB
testcase_32 AC 577 ms
136,844 KB
testcase_33 AC 377 ms
109,220 KB
testcase_34 AC 522 ms
136,940 KB
testcase_35 AC 1,906 ms
135,700 KB
testcase_36 AC 586 ms
137,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
N = int(input())
A = sorted((tuple(map(int, input().split())) for _ in range(N)),
        key=lambda x: (x[0],-x[1]))
P = sorted((t[1],i) for i,t in enumerate(A))
B = [0]*(N+2)
def U(i, v):
    while i <= N:
        B[i] = max(B[i], v)
        i += i&-i
def Q(i):
    v = 0
    while i > 0:
        v = max(v, B[i])
        i -= i&-i
    return v
for i in range(N)[::-1]:
    _, b, c = A[i]
    j = N-bisect(P, (b,N))
    v = Q(j)
    j = N-bisect(P, (b,i))+1
    U(j, v+c)
print(max(B))
0