結果

問題 No.1715 Dinner 2
ユーザー tamatotamato
提出日時 2021-10-22 22:18:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,444 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 81,668 KB
実行使用メモリ 75,232 KB
最終ジャッジ日時 2023-10-24 13:33:15
合計ジャッジ時間 4,369 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,492 KB
testcase_01 AC 36 ms
53,492 KB
testcase_02 AC 44 ms
61,992 KB
testcase_03 AC 37 ms
53,492 KB
testcase_04 AC 42 ms
59,732 KB
testcase_05 AC 39 ms
59,240 KB
testcase_06 AC 37 ms
53,492 KB
testcase_07 AC 41 ms
59,732 KB
testcase_08 AC 41 ms
59,240 KB
testcase_09 AC 36 ms
53,492 KB
testcase_10 AC 44 ms
59,732 KB
testcase_11 AC 166 ms
75,224 KB
testcase_12 AC 153 ms
75,228 KB
testcase_13 AC 120 ms
72,248 KB
testcase_14 AC 138 ms
75,224 KB
testcase_15 AC 148 ms
75,228 KB
testcase_16 AC 146 ms
75,220 KB
testcase_17 AC 115 ms
75,220 KB
testcase_18 AC 49 ms
68,148 KB
testcase_19 AC 49 ms
68,136 KB
testcase_20 AC 52 ms
66,100 KB
testcase_21 AC 45 ms
63,836 KB
testcase_22 AC 46 ms
68,072 KB
testcase_23 AC 52 ms
72,164 KB
testcase_24 AC 50 ms
66,096 KB
testcase_25 AC 62 ms
72,380 KB
testcase_26 AC 62 ms
75,192 KB
testcase_27 AC 57 ms
70,188 KB
testcase_28 AC 60 ms
72,236 KB
testcase_29 AC 58 ms
72,236 KB
testcase_30 AC 59 ms
73,268 KB
testcase_31 AC 59 ms
72,236 KB
testcase_32 AC 196 ms
75,228 KB
testcase_33 AC 193 ms
75,232 KB
testcase_34 AC 211 ms
75,224 KB
testcase_35 AC 208 ms
75,232 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, D = map(int, input().split())
    P = []
    Q = []
    for _ in range(N):
        p, q = map(int, input().split())
        P.append(p)
        Q.append(q)

    ok = -10 ** 9
    ng = 0
    mid = (ok + ng) // 2
    while ng - ok > 1:
        prev = -1
        cur = 0
        flg = 1
        for d in range(D):
            best = -10**9
            best_i = []
            for i in range(N):
                if cur - P[i] < mid:
                    continue
                if i == prev:
                    continue
                cur_new = cur - P[i] + Q[i]
                if cur_new > best:
                    best_i = [i]
                    best = cur_new
                elif cur_new == best:
                    best_i.append(i)
            if not best_i:
                flg = 0
                break
            if len(best_i) > 1:
                PP = []
                for i in best_i:
                    PP.append((P[i], i))
                PP.sort(key=lambda x: x[0])
                if (D - d) & 1:
                    prev = PP[0][1]
                else:
                    prev = PP[1][1]
            else:
                prev = best_i[0]
            cur = best
        if flg == 0:
            ng = mid
        else:
            ok = mid
        mid = (ok + ng) // 2
    print(ok)


if __name__ == '__main__':
    main()
0