結果

問題 No.817 Coin donation
ユーザー ああいいああいい
提出日時 2022-01-27 15:07:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 83,128 KB
最終ジャッジ日時 2023-08-26 15:25:36
合計ジャッジ時間 3,120 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,212 KB
testcase_01 AC 73 ms
71,460 KB
testcase_02 AC 75 ms
75,252 KB
testcase_03 AC 78 ms
75,128 KB
testcase_04 AC 73 ms
71,060 KB
testcase_05 AC 100 ms
76,664 KB
testcase_06 AC 112 ms
77,680 KB
testcase_07 AC 115 ms
77,728 KB
testcase_08 AC 161 ms
81,372 KB
testcase_09 AC 120 ms
78,308 KB
testcase_10 AC 186 ms
82,868 KB
testcase_11 AC 187 ms
83,128 KB
testcase_12 AC 185 ms
82,956 KB
testcase_13 AC 70 ms
71,112 KB
testcase_14 AC 72 ms
71,544 KB
testcase_15 AC 71 ms
71,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())

edge = []
for _ in range(N):
    a,b = map(int,input().split())
    edge.append((a,b))
    
def check(x):
    count = 0
    for a,b in edge:
        if a <= x <= b:
            count += x - a + 1
        elif x > b:
            count += b - a + 1
    return count >= K
start = 0
end = 10 ** 9
while end - start > 1:
    mid = (end + start) // 2
    if check(mid):
        end = mid
    else:
        start = mid
print(end)
0