結果

問題 No.817 Coin donation
ユーザー titiatitia
提出日時 2019-04-19 21:40:56
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 644 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 1,240 ms
使用メモリ 27,516 KB
最終ジャッジ日時 2022-11-22 07:41:06
合計ジャッジ時間 4,556 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 16 ms
7,696 KB
testcase_01 AC 15 ms
7,704 KB
testcase_02 AC 16 ms
7,580 KB
testcase_03 AC 17 ms
7,776 KB
testcase_04 AC 15 ms
7,752 KB
testcase_05 AC 33 ms
8,356 KB
testcase_06 AC 96 ms
10,280 KB
testcase_07 AC 114 ms
10,960 KB
testcase_08 AC 432 ms
21,288 KB
testcase_09 AC 135 ms
11,596 KB
testcase_10 AC 639 ms
27,516 KB
testcase_11 AC 634 ms
27,384 KB
testcase_12 AC 644 ms
27,380 KB
testcase_13 AC 15 ms
7,784 KB
testcase_14 AC 15 ms
7,696 KB
testcase_15 AC 15 ms
7,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

MIN=1
MAX=10**9

while MIN!=MAX:
    x=(MIN+MAX)//2
    

    SUM=0
    for l,r in AB:
        if x<l:
            continue
        
        if x>r:
            SUM+=(r-l+1)

        else:
            SUM+=(x-l+1)

    #print(x,MIN,MAX,SUM)

    if SUM>=K:
        MAX=x
    else:
        MIN=x+1

print(MIN)
0