結果

問題 No.817 Coin donation
ユーザー tktk_snsn
提出日時 2020-12-26 02:50:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 86,784 KB
最終ジャッジ日時 2024-09-22 21:36:51
合計ジャッジ時間 2,559 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
AB = tuple(tuple(map(int, input().split())) for _ in range(N))


def C(x):
    cnt = 0
    for a, b in AB:
        if x < a:
            continue
        b = min(b, x)
        cnt += b - a + 1
    return cnt >= K


l = 0
r = 10 ** 9 + 2
while r - l > 1:
    m = (r + l) // 2
    if C(m):
        r = m
    else:
        l = m
print(r)
0