結果

問題 No.817 Coin donation
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-04-20 02:00:32
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,180 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 11,956 KB
実行使用メモリ 29,804 KB
最終ジャッジ日時 2023-10-24 22:55:45
合計ジャッジ時間 6,226 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,164 KB
testcase_01 AC 29 ms
10,164 KB
testcase_02 AC 29 ms
10,176 KB
testcase_03 AC 30 ms
10,192 KB
testcase_04 AC 28 ms
10,168 KB
testcase_05 AC 61 ms
10,736 KB
testcase_06 AC 172 ms
12,508 KB
testcase_07 AC 216 ms
13,300 KB
testcase_08 AC 830 ms
23,748 KB
testcase_09 AC 254 ms
13,828 KB
testcase_10 AC 1,174 ms
29,804 KB
testcase_11 AC 1,173 ms
29,804 KB
testcase_12 AC 1,180 ms
29,804 KB
testcase_13 AC 29 ms
10,164 KB
testcase_14 AC 29 ms
10,164 KB
testcase_15 AC 28 ms
10,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int, input().split())
AB  = [list(map(int, input().split())) for _ in range(N)]

ok = 10**9
ng = 0
mid = (ok+ng)//2
while abs(ok-ng) > 1:
    tmpCount = 0
    for a,b in AB:
        n = b-a+1
        if b < mid:
            tmpCount += n
        elif mid < a:
            pass
        elif a <= mid <= b:
            tmpCount += mid - a + 1
        
    if tmpCount >= K:
        ok = mid
    else:
        ng = mid
    mid = (ok+ng)//2
print(ok)
0