結果

問題 No.817 Coin donation
ユーザー alexara1123alexara1123
提出日時 2019-09-22 19:01:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 751 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 81,576 KB
実行使用メモリ 86,328 KB
最終ジャッジ日時 2023-10-19 07:22:18
合計ジャッジ時間 4,809 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,524 KB
testcase_01 AC 50 ms
61,580 KB
testcase_02 AC 46 ms
59,504 KB
testcase_03 AC 50 ms
61,576 KB
testcase_04 AC 48 ms
61,576 KB
testcase_05 AC 104 ms
76,272 KB
testcase_06 AC 174 ms
77,472 KB
testcase_07 AC 199 ms
77,860 KB
testcase_08 AC 538 ms
83,120 KB
testcase_09 AC 187 ms
78,056 KB
testcase_10 AC 747 ms
86,316 KB
testcase_11 AC 749 ms
86,320 KB
testcase_12 AC 751 ms
86,328 KB
testcase_13 AC 39 ms
53,524 KB
testcase_14 AC 39 ms
53,524 KB
testcase_15 AC 39 ms
53,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def main():
    n, k = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(n)]

    def ok(v):

        s = 0
        for i in range(n):
            # 境界より大きい硬貨はカウントしない
            s += max(0, min(v, ab[i][1]) - ab[i][0] + 1)

        if s >= k:
            return True
        else:
            return False

    l, r = 0, 10**18
    for i in range(200):
        m = (l + r) / 2
        if ok(m):
            r = m
        else:
            l = m
    print(math.ceil(m))


if __name__ == '__main__':
    main()
0