結果

問題 No.777 再帰的ケーキ
ユーザー torikuminotorikumino
提出日時 2019-01-11 23:46:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,192 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 1,171 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 136,432 KB
最終ジャッジ日時 2023-08-20 18:00:29
合計ジャッジ時間 12,832 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
71,360 KB
testcase_01 AC 58 ms
71,340 KB
testcase_02 AC 58 ms
71,512 KB
testcase_03 AC 57 ms
71,332 KB
testcase_04 AC 58 ms
71,512 KB
testcase_05 AC 58 ms
71,640 KB
testcase_06 AC 57 ms
71,376 KB
testcase_07 AC 60 ms
71,408 KB
testcase_08 AC 59 ms
71,120 KB
testcase_09 AC 58 ms
71,532 KB
testcase_10 AC 59 ms
71,624 KB
testcase_11 AC 59 ms
71,360 KB
testcase_12 AC 57 ms
71,252 KB
testcase_13 AC 58 ms
71,668 KB
testcase_14 AC 59 ms
71,152 KB
testcase_15 AC 58 ms
71,256 KB
testcase_16 AC 59 ms
71,368 KB
testcase_17 AC 62 ms
71,528 KB
testcase_18 AC 60 ms
71,488 KB
testcase_19 AC 58 ms
71,384 KB
testcase_20 AC 60 ms
71,372 KB
testcase_21 AC 138 ms
78,276 KB
testcase_22 AC 99 ms
78,100 KB
testcase_23 AC 93 ms
77,964 KB
testcase_24 AC 91 ms
77,948 KB
testcase_25 AC 100 ms
78,300 KB
testcase_26 AC 99 ms
78,204 KB
testcase_27 AC 101 ms
78,088 KB
testcase_28 AC 1,059 ms
130,804 KB
testcase_29 AC 1,029 ms
131,176 KB
testcase_30 AC 1,055 ms
134,604 KB
testcase_31 AC 1,192 ms
135,056 KB
testcase_32 AC 326 ms
131,616 KB
testcase_33 AC 237 ms
105,384 KB
testcase_34 AC 298 ms
128,052 KB
testcase_35 AC 1,018 ms
136,432 KB
testcase_36 AC 334 ms
132,556 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 = [0]*N
G = [0]*N
t = sorted(range(N), key=lambda x: A[x][1])
x = -1
for i in range(N)[::-1]:
    j = t[i]
    P[j] = i
    if x>=0 and A[j][1]==A[x][1]:
        G[j] = G[x]
    else:
        G[j] = i+1
        x = j
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-G[i]
    v = Q(j)
    j = N-P[i]
    U(j, v+c)
print(max(B))
0