結果

問題 No.817 Coin donation
ユーザー alexara1123alexara1123
提出日時 2019-09-22 18:59:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 81,560 KB
実行使用メモリ 86,316 KB
最終ジャッジ日時 2023-10-19 07:22:13
合計ジャッジ時間 4,253 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,524 KB
testcase_01 AC 45 ms
59,500 KB
testcase_02 AC 46 ms
59,504 KB
testcase_03 AC 47 ms
61,576 KB
testcase_04 AC 45 ms
59,504 KB
testcase_05 AC 90 ms
76,264 KB
testcase_06 AC 132 ms
77,476 KB
testcase_07 AC 141 ms
77,856 KB
testcase_08 AC 315 ms
83,120 KB
testcase_09 AC 141 ms
78,048 KB
testcase_10 AC 429 ms
86,312 KB
testcase_11 AC 428 ms
86,308 KB
testcase_12 AC 429 ms
86,316 KB
testcase_13 AC 39 ms
53,524 KB
testcase_14 WA -
testcase_15 AC 40 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(100):
        m = (l + r) / 2
        if ok(m):
            r = m
        else:
            l = m
    print(math.ceil(m))


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