結果

問題 No.817 Coin donation
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-07-25 06:22:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 85,400 KB
最終ジャッジ日時 2024-04-09 23:56:12
合計ジャッジ時間 2,773 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,956 KB
testcase_01 AC 43 ms
55,248 KB
testcase_02 AC 45 ms
61,988 KB
testcase_03 AC 45 ms
62,024 KB
testcase_04 AC 41 ms
55,880 KB
testcase_05 AC 54 ms
69,968 KB
testcase_06 AC 66 ms
77,204 KB
testcase_07 AC 75 ms
77,848 KB
testcase_08 AC 120 ms
81,156 KB
testcase_09 AC 80 ms
77,460 KB
testcase_10 AC 146 ms
84,836 KB
testcase_11 AC 145 ms
84,792 KB
testcase_12 AC 149 ms
85,400 KB
testcase_13 AC 43 ms
56,216 KB
testcase_14 AC 42 ms
56,656 KB
testcase_15 AC 41 ms
55,568 KB
権限があれば一括ダウンロードができます

ソースコード

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