結果

問題 No.817 Coin donation
ユーザー titiatitia
提出日時 2019-04-19 21:40:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 740 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 11,852 KB
実行使用メモリ 29,700 KB
最終ジャッジ日時 2023-10-24 00:43:17
合計ジャッジ時間 4,341 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,060 KB
testcase_01 AC 28 ms
10,060 KB
testcase_02 AC 28 ms
10,072 KB
testcase_03 AC 29 ms
10,088 KB
testcase_04 AC 28 ms
10,064 KB
testcase_05 AC 47 ms
10,628 KB
testcase_06 AC 116 ms
12,528 KB
testcase_07 AC 139 ms
13,320 KB
testcase_08 AC 478 ms
23,640 KB
testcase_09 AC 162 ms
13,848 KB
testcase_10 AC 710 ms
29,700 KB
testcase_11 AC 740 ms
29,700 KB
testcase_12 AC 702 ms
29,700 KB
testcase_13 AC 27 ms
10,060 KB
testcase_14 AC 27 ms
10,060 KB
testcase_15 AC 27 ms
10,060 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