結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 13 ms
5,376 KB
testcase_07 AC 16 ms
5,376 KB
testcase_08 AC 60 ms
5,376 KB
testcase_09 AC 18 ms
5,376 KB
testcase_10 AC 86 ms
5,376 KB
testcase_11 AC 85 ms
5,376 KB
testcase_12 AC 85 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
5,376 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)

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