結果
問題 | No.2808 Concentration |
ユーザー | hirayuu_yc |
提出日時 | 2024-07-08 18:14:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 425 ms / 2,000 ms |
コード長 | 2,725 bytes |
コンパイル時間 | 657 ms |
コンパイル使用メモリ | 82,096 KB |
実行使用メモリ | 136,956 KB |
最終ジャッジ日時 | 2024-07-10 15:20:01 |
合計ジャッジ時間 | 19,718 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 406 ms
136,504 KB |
testcase_01 | AC | 397 ms
136,192 KB |
testcase_02 | AC | 389 ms
136,932 KB |
testcase_03 | AC | 38 ms
56,292 KB |
testcase_04 | AC | 37 ms
55,312 KB |
testcase_05 | AC | 39 ms
55,080 KB |
testcase_06 | AC | 259 ms
98,084 KB |
testcase_07 | AC | 197 ms
86,516 KB |
testcase_08 | AC | 90 ms
76,916 KB |
testcase_09 | AC | 302 ms
113,516 KB |
testcase_10 | AC | 300 ms
112,800 KB |
testcase_11 | AC | 212 ms
92,616 KB |
testcase_12 | AC | 378 ms
131,644 KB |
testcase_13 | AC | 162 ms
85,396 KB |
testcase_14 | AC | 384 ms
124,636 KB |
testcase_15 | AC | 372 ms
125,608 KB |
testcase_16 | AC | 408 ms
125,496 KB |
testcase_17 | AC | 401 ms
136,604 KB |
testcase_18 | AC | 281 ms
102,568 KB |
testcase_19 | AC | 385 ms
129,260 KB |
testcase_20 | AC | 350 ms
125,600 KB |
testcase_21 | AC | 304 ms
112,792 KB |
testcase_22 | AC | 291 ms
108,292 KB |
testcase_23 | AC | 374 ms
126,516 KB |
testcase_24 | AC | 273 ms
103,252 KB |
testcase_25 | AC | 386 ms
121,140 KB |
testcase_26 | AC | 420 ms
135,560 KB |
testcase_27 | AC | 388 ms
136,384 KB |
testcase_28 | AC | 393 ms
136,548 KB |
testcase_29 | AC | 379 ms
136,644 KB |
testcase_30 | AC | 377 ms
136,420 KB |
testcase_31 | AC | 397 ms
135,444 KB |
testcase_32 | AC | 396 ms
136,448 KB |
testcase_33 | AC | 389 ms
133,804 KB |
testcase_34 | AC | 386 ms
136,536 KB |
testcase_35 | AC | 382 ms
136,444 KB |
testcase_36 | AC | 425 ms
136,596 KB |
testcase_37 | AC | 395 ms
136,476 KB |
testcase_38 | AC | 373 ms
136,464 KB |
testcase_39 | AC | 410 ms
135,584 KB |
testcase_40 | AC | 403 ms
136,456 KB |
testcase_41 | AC | 408 ms
136,532 KB |
testcase_42 | AC | 423 ms
136,956 KB |
testcase_43 | AC | 386 ms
136,360 KB |
testcase_44 | AC | 391 ms
136,532 KB |
testcase_45 | AC | 396 ms
136,184 KB |
testcase_46 | AC | 39 ms
56,072 KB |
testcase_47 | AC | 40 ms
56,100 KB |
testcase_48 | AC | 39 ms
55,036 KB |
testcase_49 | AC | 39 ms
55,064 KB |
testcase_50 | AC | 38 ms
54,712 KB |
testcase_51 | AC | 38 ms
54,760 KB |
testcase_52 | AC | 38 ms
55,128 KB |
testcase_53 | AC | 38 ms
55,116 KB |
testcase_54 | AC | 38 ms
55,268 KB |
testcase_55 | AC | 38 ms
55,996 KB |
ソースコード
from collections import deque class FoldableDeque: def __init__(self,op,e)->None: self.op=op self.e=e self.left=deque() self.leftop=deque([e()]) self.right=deque() self.rightop=deque([e()]) def append(self,v:any)->None: self.right.append(v) self.rightop.append(self.op(self.rightop[-1],v)) def appendleft(self,v:any)->None: self.left.append(v) self.leftop.append(self.op(v,self.leftop[-1])) def pop(self)->any: if len(self.right)==0: nl=[] while len(self.left)>0: nl.append(self.popleft()) self.leftop=deque([self.e()]) half=len(nl)//2 for i in nl[half:]: self.append(i) for i in nl[:half][::-1]: self.appendleft(i) self.rightop.pop() return self.right.pop() def popleft(self)->any: if len(self.left)==0: nr=[] while len(self.right)>0: nr.append(self.pop()) self.rightop=deque([self.e()]) half=len(nr)//2 for i in nr[half:]: self.appendleft(i) for i in nr[:half][::-1]: self.append(i) self.leftop.pop() return self.left.pop() def get_all(self): return self.op(self.leftop[-1],self.rightop[-1]) def __len__(self)->int: return len(self.left)+len(self.right) def __str__(self)->str: return str(list(self.left)[::-1])+str(list(self.right)) class FoldableQueue(FoldableDeque): def pop(self): assert False def popleft(self)->any: if len(self.left)==0: for i in reversed(self.right): self.appendleft(i) self.right=deque() self.rightop=deque([self.e()]) self.leftop.pop() return self.left.pop() N,S,H=map(int,input().split()) segs=[(-(1<<60),-(1<<60),0)]+[tuple(map(int,input().split())) for i in range(N)]+[(1<<60,1<<60,0)] segs=[(x,y,z) for x,y,z in segs if y-x<=S] N=len(segs) last_sleep=[-1]*N pnt=0 for i in range(1,N): while segs[i][0]-segs[pnt+1][1]>=H: pnt+=1 last_sleep[i]=pnt last_listen=[-1]*N pnt=0 for i in range(1,N): while segs[i][1]-segs[pnt][0]>S: pnt+=1 last_listen[i]=pnt cum=[0]*N for i in range(1,N): cum[i]=cum[i-1]+segs[i][2] sleep_dp=[0]*N listen_dp=FoldableQueue(lambda x,y:max(x,y),lambda:-(1<<60)) for i in range(1,N): listen_dp.append(sleep_dp[last_sleep[i]]-cum[i-1]) while len(listen_dp)>i+1-last_listen[i]: listen_dp.popleft() sleep_dp[i]=max(sleep_dp[i-1],listen_dp.get_all()+cum[i]) print(sleep_dp[-1])