結果

問題 No.817 Coin donation
ユーザー chocoruskchocorusk
提出日時 2019-04-20 07:21:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 55,932 KB
実行使用メモリ 5,040 KB
最終ジャッジ日時 2023-10-25 08:27:35
合計ジャッジ時間 1,586 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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)/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+1;
        else x2=x;
    }
    cout<<x1<<endl;
    return 0;
}
0