結果

問題 No.817 Coin donation
ユーザー recososorecososo
提出日時 2020-02-27 11:49:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 165,072 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 16:51:49
合計ジャッジ時間 3,129 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;cin >> n >> k;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    int l=0,r=1e9+1;
    while(r-l>1){
        int mid=(l+r)/2;
        long long sum=0;
        for(int i=0;i<n;i++){
            if(a[i]>=mid){
                continue;
            }
            else{
                if(b[i]<mid){
                    sum+=b[i]-a[i]+1;
                }
                else{
                    sum+=mid-a[i];
                }
            }
        }
        if(sum<k){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    cout << l << endl;
}
0