結果

問題 No.817 Coin donation
ユーザー sinsincoscossinsincoscos
提出日時 2019-04-19 21:39:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 65,196 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 17:33:31
合計ジャッジ時間 1,617 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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