結果

問題 No.1826 Fruits Collecting
ユーザー titiatitia
提出日時 2022-01-29 01:39:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,376 ms / 2,000 ms
コード長 1,358 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 273,144 KB
最終ジャッジ日時 2023-08-29 01:20:51
合計ジャッジ時間 30,980 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
76,824 KB
testcase_01 AC 110 ms
78,404 KB
testcase_02 AC 108 ms
77,996 KB
testcase_03 AC 111 ms
78,652 KB
testcase_04 AC 91 ms
76,816 KB
testcase_05 AC 509 ms
157,268 KB
testcase_06 AC 837 ms
179,224 KB
testcase_07 AC 615 ms
155,952 KB
testcase_08 AC 151 ms
85,788 KB
testcase_09 AC 818 ms
199,940 KB
testcase_10 AC 569 ms
175,400 KB
testcase_11 AC 548 ms
170,436 KB
testcase_12 AC 281 ms
112,576 KB
testcase_13 AC 191 ms
91,716 KB
testcase_14 AC 241 ms
104,456 KB
testcase_15 AC 1,332 ms
272,364 KB
testcase_16 AC 1,312 ms
273,044 KB
testcase_17 AC 1,279 ms
272,736 KB
testcase_18 AC 1,296 ms
272,884 KB
testcase_19 AC 1,288 ms
273,080 KB
testcase_20 AC 1,340 ms
273,144 KB
testcase_21 AC 1,333 ms
272,872 KB
testcase_22 AC 1,324 ms
272,860 KB
testcase_23 AC 1,343 ms
272,888 KB
testcase_24 AC 1,376 ms
272,928 KB
testcase_25 AC 71 ms
71,364 KB
testcase_26 AC 73 ms
71,248 KB
testcase_27 AC 71 ms
71,248 KB
testcase_28 AC 74 ms
71,364 KB
testcase_29 AC 75 ms
71,248 KB
testcase_30 AC 357 ms
122,308 KB
testcase_31 AC 616 ms
175,056 KB
testcase_32 AC 340 ms
120,380 KB
testcase_33 AC 989 ms
224,160 KB
testcase_34 AC 791 ms
182,636 KB
testcase_35 AC 243 ms
104,528 KB
testcase_36 AC 892 ms
178,744 KB
testcase_37 AC 620 ms
157,092 KB
testcase_38 AC 449 ms
133,464 KB
testcase_39 AC 390 ms
171,904 KB
testcase_40 AC 481 ms
199,924 KB
testcase_41 AC 193 ms
101,764 KB
testcase_42 AC 127 ms
79,676 KB
testcase_43 AC 72 ms
71,380 KB
testcase_44 AC 75 ms
71,472 KB
testcase_45 AC 71 ms
71,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from operator import itemgetter

N=int(input())

B=[list(map(int,input().split())) for i in range(N)]
B2=[[0,0,0]]

for t,x,v in B:
    B2.append([t+x,t-x,v])

#print(B2)



SS=[0]
for x,y,v in B2:
    SS.append(x)
    SS.append(y)

SS=sorted(set(SS))

D={SS[i]:i for i in range(len(SS))}

for i in range(N+1):
    B2[i][0]=D[B2[i][0]]
    B2[i][1]=D[B2[i][1]]

#print(B2)

B2.sort()

def seg_function(x,y): # Segment treeで扱うfunction
    return max(x,y)

seg_el=1<<((len(SS)+5).bit_length()) # Segment treeの台の要素数
SEG=[-1<<60]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

def update(n,x,seg_el): # A[n]をxへ更新
    i=n+seg_el
    SEG[i]=x
    i>>=1 # 子ノードへ
    
    while i!=0:
        SEG[i]=seg_function(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r): # 区間[l,r)に関するseg_functionを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=-1<<60

    while L<R:
        if L & 1:
            ANS=seg_function(ANS , SEG[L])
            L+=1

        if R & 1:
            R-=1
            ANS=seg_function(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

update(D[0],0,seg_el)

for x,y,v in B2:
    if x<D[0]:
        continue
    A=getvalues(0,y+1)
    #print(x,y,v,A)
    update(y,A+v,seg_el)

print(SEG[1])
    
0