結果

問題 No.817 Coin donation
ユーザー koi_kotyakoi_kotya
提出日時 2019-04-19 22:18:52
言語 Ruby
(3.2.2)
結果
AC  
実行時間 614 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 11,936 KB
実行使用メモリ 17,764 KB
最終ジャッジ日時 2023-10-24 04:09:11
合計ジャッジ時間 6,677 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
16,092 KB
testcase_01 AC 83 ms
16,092 KB
testcase_02 AC 82 ms
16,092 KB
testcase_03 AC 83 ms
16,092 KB
testcase_04 AC 83 ms
16,092 KB
testcase_05 AC 99 ms
16,240 KB
testcase_06 AC 151 ms
16,400 KB
testcase_07 AC 172 ms
16,456 KB
testcase_08 AC 445 ms
17,276 KB
testcase_09 AC 188 ms
16,504 KB
testcase_10 AC 613 ms
17,764 KB
testcase_11 AC 614 ms
17,764 KB
testcase_12 AC 610 ms
17,764 KB
testcase_13 AC 84 ms
16,092 KB
testcase_14 AC 84 ms
16,092 KB
testcase_15 AC 87 ms
16,092 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,k = gets.split.map(&:to_i)
a,b = 2.times.map{Array.new(n,0)}
n.times do |i|
    a[i],b[i] = gets.split.map(&:to_i)
end
min = 1
max = 10**15
while max-min > 1
    mid = (min+max)/2
    cnt = 0
    n.times do |i|
        if a[i] <= mid
            cnt += (b[i] < mid ? b[i] : mid)-a[i]+1
        end
    end
    if cnt < k
        min = mid
    else
        max = mid
    end
end
puts max
0