結果

問題 No.1715 Dinner 2
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-10-22 22:06:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 988 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 75,592 KB
最終ジャッジ日時 2023-10-24 13:16:24
合計ジャッジ時間 4,815 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,380 KB
testcase_01 AC 37 ms
53,380 KB
testcase_02 AC 42 ms
59,808 KB
testcase_03 AC 37 ms
53,380 KB
testcase_04 AC 42 ms
59,812 KB
testcase_05 AC 41 ms
59,468 KB
testcase_06 AC 38 ms
53,380 KB
testcase_07 AC 44 ms
59,808 KB
testcase_08 AC 42 ms
59,468 KB
testcase_09 AC 37 ms
53,380 KB
testcase_10 AC 41 ms
59,800 KB
testcase_11 AC 188 ms
75,560 KB
testcase_12 AC 164 ms
72,364 KB
testcase_13 AC 144 ms
73,388 KB
testcase_14 AC 161 ms
75,592 KB
testcase_15 AC 173 ms
75,492 KB
testcase_16 AC 162 ms
73,660 KB
testcase_17 AC 126 ms
72,364 KB
testcase_18 AC 59 ms
68,244 KB
testcase_19 AC 63 ms
70,296 KB
testcase_20 AC 58 ms
68,232 KB
testcase_21 AC 55 ms
66,172 KB
testcase_22 AC 59 ms
68,232 KB
testcase_23 AC 61 ms
68,248 KB
testcase_24 AC 67 ms
72,392 KB
testcase_25 AC 78 ms
72,916 KB
testcase_26 AC 75 ms
72,916 KB
testcase_27 AC 71 ms
72,372 KB
testcase_28 AC 77 ms
72,972 KB
testcase_29 AC 75 ms
72,384 KB
testcase_30 AC 72 ms
72,364 KB
testcase_31 AC 79 ms
72,916 KB
testcase_32 AC 216 ms
75,500 KB
testcase_33 AC 203 ms
72,404 KB
testcase_34 AC 230 ms
74,008 KB
testcase_35 AC 236 ms
75,520 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

同じ2種類のみを繰り返すのが最適?
最後の方は、そうとは限らない

二分探索か?
最低を下回らない範囲内で、一番跳ね返りが大きいのを選ぶのが最適

"""

import sys
from sys import stdin
import math

N,D = map(int,stdin.readline().split())

PQ = []
PG = []

for i in range(N):
    P,Q = map(int,stdin.readline().split())
    PQ.append((P,Q))
    PG.append( (P,Q-P) )

PG.sort()

r = 0
l = -10**9

while r-l != 1:

    m = (l+r)//2

    now = 0
    last = None

    able = True

    for day in range(D):

        nind = None
    
        for i in range(N):
            p,g = PG[i]
            if now - p >= m and i != last and (nind == None or PG[nind][1] < g):
                nind = i
            if now - p < m:
                break

        if nind == None:
            able = False
            break

        last = nind
        now += PG[nind][1]

    if able:
        l = m
    else:
        r = m

print (l)
        
0