結果

問題 No.817 Coin donation
ユーザー chocoruskchocorusk
提出日時 2019-04-20 07:10:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 561 bytes
コンパイル時間 1,872 ms
コンパイル使用メモリ 55,760 KB
実行使用メモリ 5,072 KB
最終ジャッジ日時 2023-10-25 08:16:24
合計ジャッジ時間 4,149 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 3 ms
4,992 KB
testcase_03 AC 3 ms
4,992 KB
testcase_04 AC 3 ms
4,992 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,992 KB
testcase_14 AC 2 ms
4,992 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

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