結果

問題 No.817 Coin donation
ユーザー sinsincoscossinsincoscos
提出日時 2019-04-19 21:39:14
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 403 ms
使用メモリ 5,088 KB
最終ジャッジ日時 2022-11-22 07:27:48
合計ジャッジ時間 1,831 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,540 KB
testcase_01 AC 1 ms
3,536 KB
testcase_02 AC 1 ms
3,560 KB
testcase_03 AC 2 ms
3,380 KB
testcase_04 AC 2 ms
3,484 KB
testcase_05 AC 3 ms
3,500 KB
testcase_06 AC 11 ms
3,632 KB
testcase_07 AC 14 ms
3,692 KB
testcase_08 AC 54 ms
4,600 KB
testcase_09 AC 16 ms
3,772 KB
testcase_10 AC 77 ms
5,088 KB
testcase_11 AC 77 ms
5,084 KB
testcase_12 AC 77 ms
4,968 KB
testcase_13 AC 1 ms
3,540 KB
testcase_14 AC 1 ms
3,432 KB
testcase_15 AC 1 ms
3,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;
ll N,K;
ll A[100010],B[100010];
int main(){
    cin >> N >> K;
    for(int i=1;i<=N;i++){
        cin >> A[i] >> B[i];
    }
    int l = 0,r = 1e9+1;
    while(l+1<r){
        int m = (l+r)/2;
        ll cnt = 0;
        for(int i=1;i<=N;i++){
            if(m<A[i]) continue;
            cnt += min(m-A[i]+1,B[i]-A[i]+1);
        }
        if(cnt<K) l = m;
        else r = m;
    }
    cout << r << endl;
}
0