結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
5,376 KB
testcase_06 AC 13 ms
5,376 KB
testcase_07 AC 15 ms
5,376 KB
testcase_08 AC 56 ms
5,376 KB
testcase_09 AC 18 ms
5,376 KB
testcase_10 AC 83 ms
5,376 KB
testcase_11 AC 80 ms
5,376 KB
testcase_12 AC 79 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;
    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