結果
問題 | No.448 ゆきこーだーの雨と雪 (3) |
ユーザー | mkawa2 |
提出日時 | 2020-04-25 18:24:44 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,298 bytes |
コンパイル時間 | 136 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 80,968 KB |
最終ジャッジ日時 | 2024-04-25 03:03:07 |
合計ジャッジ時間 | 14,548 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
10,752 KB |
testcase_01 | AC | 30 ms
10,752 KB |
testcase_02 | AC | 29 ms
10,880 KB |
testcase_03 | AC | 30 ms
10,880 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 34 ms
11,008 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 30 ms
10,880 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 106 ms
18,688 KB |
testcase_14 | AC | 114 ms
19,404 KB |
testcase_15 | AC | 234 ms
32,456 KB |
testcase_16 | AC | 483 ms
52,468 KB |
testcase_17 | AC | 339 ms
44,884 KB |
testcase_18 | AC | 79 ms
17,792 KB |
testcase_19 | AC | 649 ms
67,940 KB |
testcase_20 | AC | 181 ms
26,144 KB |
testcase_21 | AC | 533 ms
59,044 KB |
testcase_22 | AC | 210 ms
27,048 KB |
testcase_23 | AC | 582 ms
59,304 KB |
testcase_24 | AC | 154 ms
24,084 KB |
testcase_25 | AC | 566 ms
58,648 KB |
testcase_26 | AC | 95 ms
17,280 KB |
testcase_27 | AC | 441 ms
45,932 KB |
testcase_28 | AC | 445 ms
49,304 KB |
testcase_29 | AC | 235 ms
30,680 KB |
testcase_30 | AC | 652 ms
68,940 KB |
testcase_31 | AC | 88 ms
18,688 KB |
testcase_32 | AC | 95 ms
19,328 KB |
testcase_33 | AC | 698 ms
72,156 KB |
testcase_34 | AC | 624 ms
62,372 KB |
testcase_35 | AC | 825 ms
80,968 KB |
testcase_36 | AC | 551 ms
62,376 KB |
testcase_37 | AC | 645 ms
67,016 KB |
testcase_38 | AC | 519 ms
62,376 KB |
ソースコード
import sys sys.setrecursionlimit(10 ** 6) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): def ok(m): pt=-inf mxd=dd[m] # Ameの最大難易度をmxdとする # Yukiに振る仕事(難易度がmxdより大きい仕事)だけをみたとき # 時間の間隔がk以上空いているかチェックする for t,d in td: if d<=mxd:continue if t-pt<k:return False pt=t return True inf=10**10 n,k=MI() td=LLI(n) # Ameの難易度最大値を二分探索 dd=[0]+sorted(set(d for t,d in td)) #print(dd) l=-1 r=len(dd) while l+1<r: m=(l+r)//2 if ok(m):r=m else:l=m mxd=dd[r] print(mxd) if r==0: print(0) exit() # Ameの最大難易度mxd以内の仕事のうち、Yukiに渡せるものをできるだけ渡す # Yukiの確定している仕事時刻を集計 ytt=[t for t,d in td if d>mxd] # Ameの仕事のうち、Yukiの仕事から時間がk以上離れているものを集める # ついでにAmeの難易度合計totも計算 tot=0 i=0 cando=[] for t,d in td: if d>mxd:continue tot+=d while i<len(ytt)-1 and t>ytt[i]+k:i+=1 if abs(t-ytt[i])>=k:cando.append((t,d)) # candoの中から、AmeからYukiに渡す仕事の難易度合計の最大値mxを求める # DPみたいな感じで # 時間順に見ていって、k時間以上前の最大難易度premaxに今の難易度を足していく premax=0 # 処理の終わった、時刻と合計難易度をttとsdに入れていく tt=[-inf] sd=[0] mx=0 for t,d in cando: # 時刻tからk以上離れている合計難易度の最大値を作る while i<len(tt) and tt[i]<=t-k: premax=max(premax,sd[i]) i+=1 # この仕事をやるときの最大難易度cur cur=premax+d tt.append(t) sd.append(cur) mx=max(mx,cur) # totのうちmxをYukiに渡すので、引き算するとAmeの難易度合計 print(tot-mx) main()