結果

問題 No.817 Coin donation
ユーザー sinsincoscossinsincoscos
提出日時 2019-04-19 21:39:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 64,264 KB
実行使用メモリ 5,208 KB
最終ジャッジ日時 2023-10-24 00:30:25
合計ジャッジ時間 1,794 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 12 ms
4,348 KB
testcase_07 AC 16 ms
4,348 KB
testcase_08 AC 58 ms
4,728 KB
testcase_09 AC 19 ms
4,348 KB
testcase_10 AC 83 ms
5,208 KB
testcase_11 AC 84 ms
5,208 KB
testcase_12 AC 83 ms
5,208 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 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