結果

問題 No.817 Coin donation
ユーザー chocorusk
提出日時 2019-04-20 07:10:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 561 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 55,796 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 03:27:12
合計ジャッジ時間 2,048 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 5 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;
int main(){
    int n;ll k;
    cin>>n>>k;
    ll a[100001], b[100001];
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
    }
    ll x1=0, x2=1e9+7;
    while(x1!=x2){
        ll x=(x1+x2+1)/2;
        ll c=0;
        for(int i=0; i<n; i++){
            if(x<a[i]) continue;
            if(x>=b[i]){
                c+=(b[i]-a[i]+1);
            }else{
                c+=(x-a[i]+1);
            }
        }
        if(c<=k) x1=x;
        else x2=x-1;
    }
    cout<<x1<<endl;
    return 0;
}
0