結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,656 KB
testcase_01 AC 36 ms
53,656 KB
testcase_02 AC 41 ms
60,124 KB
testcase_03 AC 36 ms
53,656 KB
testcase_04 AC 45 ms
60,124 KB
testcase_05 AC 39 ms
59,780 KB
testcase_06 AC 34 ms
53,656 KB
testcase_07 AC 41 ms
60,124 KB
testcase_08 AC 40 ms
59,780 KB
testcase_09 AC 37 ms
53,656 KB
testcase_10 AC 41 ms
60,116 KB
testcase_11 AC 185 ms
75,784 KB
testcase_12 AC 162 ms
72,700 KB
testcase_13 AC 148 ms
75,844 KB
testcase_14 AC 171 ms
75,832 KB
testcase_15 AC 177 ms
75,808 KB
testcase_16 AC 180 ms
75,888 KB
testcase_17 AC 138 ms
73,204 KB
testcase_18 AC 60 ms
68,568 KB
testcase_19 AC 60 ms
68,560 KB
testcase_20 AC 58 ms
68,536 KB
testcase_21 AC 56 ms
66,488 KB
testcase_22 AC 58 ms
68,560 KB
testcase_23 AC 58 ms
68,556 KB
testcase_24 AC 65 ms
72,708 KB
testcase_25 AC 77 ms
72,716 KB
testcase_26 AC 75 ms
73,244 KB
testcase_27 AC 71 ms
72,704 KB
testcase_28 AC 78 ms
73,728 KB
testcase_29 AC 74 ms
72,704 KB
testcase_30 AC 72 ms
72,680 KB
testcase_31 AC 77 ms
73,268 KB
testcase_32 AC 227 ms
75,796 KB
testcase_33 AC 208 ms
73,888 KB
testcase_34 AC 234 ms
75,888 KB
testcase_35 AC 245 ms
75,924 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 nind == None:
            able = False
            break

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

    if able:
        l = m
    else:
        r = m

print (l)
        
0