結果

問題 No.817 Coin donation
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-07-25 06:22:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 84,864 KB
最終ジャッジ日時 2024-10-02 00:53:01
合計ジャッジ時間 3,353 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

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

def is_ok(x):
    
    tmp = 0
    for a,b in AB:
        if x<a:
            continue
        elif x<=b:
            tmp += x-a+1
        else:
            tmp += b-a+1
    return tmp>=K
    
x = 0
y = 10**9 
while y-x>1:
    mid = (y+x)//2
    if is_ok(mid):
        y = mid
    else:
        x = mid
print(y)
0