結果

問題 No.817 Coin donation
ユーザー tempura_pptempura_pp
提出日時 2019-04-01 16:32:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 164,636 KB
実行使用メモリ 4,424 KB
最終ジャッジ日時 2023-09-09 20:38:00
合計ジャッジ時間 3,434 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;

int main(){
    int n,k;
    cin>>n>>k;
    assert(1<=n&&n<=100000);
    assert(1<=k&&k<=1000000000);
    int l[n],r[n];
    ll sum=0;
    rep(i,n){
        cin>>l[i]>>r[i];
        sum+=r[i]-l[i]+1;
        assert(1<=l[i]&&l[i]<=r[i]&&r[i]<=1000000000);
    }
    assert(k<sum);
    int ok=1e9+7,ng=0;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        ll cnt=0;
        rep(i,n){
            if(l[i]>mid)continue;
            cnt+=min(r[i],mid)-l[i]+1;
        }
        if(cnt>k)ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
}
0