結果

問題 No.1715 Dinner 2
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-10-22 22:17:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,426 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 76,388 KB
最終ジャッジ日時 2023-10-24 13:31:33
合計ジャッジ時間 6,664 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,556 KB
testcase_01 AC 37 ms
53,556 KB
testcase_02 AC 50 ms
62,212 KB
testcase_03 AC 40 ms
53,556 KB
testcase_04 AC 49 ms
64,332 KB
testcase_05 AC 44 ms
61,864 KB
testcase_06 AC 36 ms
53,556 KB
testcase_07 AC 46 ms
62,280 KB
testcase_08 AC 44 ms
61,864 KB
testcase_09 AC 37 ms
53,556 KB
testcase_10 AC 45 ms
62,192 KB
testcase_11 AC 312 ms
75,980 KB
testcase_12 AC 280 ms
75,880 KB
testcase_13 AC 234 ms
75,980 KB
testcase_14 AC 257 ms
75,948 KB
testcase_15 AC 282 ms
75,944 KB
testcase_16 AC 279 ms
75,872 KB
testcase_17 AC 206 ms
75,864 KB
testcase_18 AC 74 ms
74,072 KB
testcase_19 AC 80 ms
75,860 KB
testcase_20 AC 83 ms
75,860 KB
testcase_21 AC 63 ms
70,512 KB
testcase_22 AC 79 ms
75,860 KB
testcase_23 AC 84 ms
75,860 KB
testcase_24 AC 88 ms
75,860 KB
testcase_25 AC 106 ms
75,860 KB
testcase_26 AC 101 ms
75,860 KB
testcase_27 AC 99 ms
75,860 KB
testcase_28 AC 105 ms
75,860 KB
testcase_29 AC 104 ms
75,860 KB
testcase_30 AC 105 ms
75,896 KB
testcase_31 AC 115 ms
75,928 KB
testcase_32 AC 373 ms
75,864 KB
testcase_33 AC 364 ms
75,864 KB
testcase_34 AC 428 ms
76,012 KB
testcase_35 AC 414 ms
76,024 KB
testcase_36 AC 36 ms
53,556 KB
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

    filast = None

    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

        if day == 0:
            filast = nind

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

    now = 0
    last = filast
    able2 = 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:
            able2 = False
            break

        if day == 0:
            filast = nind

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

    if able or able2:
        l = m
    else:
        r = m

print (l)
0