結果

問題 No.817 Coin donation
ユーザー tempura_pptempura_pp
提出日時 2019-04-01 16:13:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 517 bytes
コンパイル時間 1,531 ms
コンパイル使用メモリ 166,168 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-04 00:53:46
合計ジャッジ時間 2,631 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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)

int main(){
    int n,k;
    cin>>n>>k;
    --k;
    int l[n],r[n];
    rep(i,n)cin>>l[i]>>r[i];
    int ok=1e9+7,ng=0;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        long long 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