結果

問題 No.817 Coin donation
ユーザー convexineqconvexineq
提出日時 2021-03-23 05:20:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 410 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 87,232 KB
最終ジャッジ日時 2023-08-16 08:36:02
合計ジャッジ時間 4,327 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
70,996 KB
testcase_01 AC 68 ms
71,260 KB
testcase_02 AC 72 ms
75,184 KB
testcase_03 AC 73 ms
75,104 KB
testcase_04 AC 69 ms
71,132 KB
testcase_05 AC 105 ms
77,856 KB
testcase_06 AC 118 ms
77,840 KB
testcase_07 AC 121 ms
78,048 KB
testcase_08 AC 184 ms
83,540 KB
testcase_09 AC 129 ms
78,176 KB
testcase_10 AC 222 ms
87,232 KB
testcase_11 AC 221 ms
86,920 KB
testcase_12 AC 216 ms
87,168 KB
testcase_13 AC 69 ms
71,348 KB
testcase_14 AC 69 ms
71,164 KB
testcase_15 AC 69 ms
71,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(x): #x円以下あつめてk枚未満か?
    r = 0
    for a,b in ab:
        if a <= x <= b:
            r += x-a+1
        elif x > b:
            r += b-a+1
    return r < k


n,k = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

ok = 0
ng = 10**9+1
while ng-ok > 1:
    mid = (ok+ng)//2
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ng)
0