結果

問題 No.817 Coin donation
ユーザー kappybarkappybar
提出日時 2020-04-11 23:02:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 168,920 KB
実行使用メモリ 4,624 KB
最終ジャッジ日時 2023-10-19 19:39:13
合計ジャッジ時間 4,326 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,624 KB
testcase_01 AC 3 ms
4,624 KB
testcase_02 AC 3 ms
4,624 KB
testcase_03 AC 3 ms
4,624 KB
testcase_04 AC 3 ms
4,624 KB
testcase_05 AC 12 ms
4,624 KB
testcase_06 AC 44 ms
4,624 KB
testcase_07 AC 56 ms
4,624 KB
testcase_08 AC 221 ms
4,624 KB
testcase_09 AC 66 ms
4,624 KB
testcase_10 AC 319 ms
4,624 KB
testcase_11 AC 311 ms
4,624 KB
testcase_12 AC 318 ms
4,624 KB
testcase_13 AC 3 ms
4,624 KB
testcase_14 AC 4 ms
4,624 KB
testcase_15 AC 3 ms
4,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<ll,ll> ;
const int INF = 1e9;
const int MOD = 1000000007;
ll n = 100005,k;
vector<P> section(n);

bool ok(ll x){
    ll cnt = 0;
    rep(i,n){
        ll l = section[i].first-1,r = section[i].second+1;
        while(r - l > 1){
            ll m = (l + r)/2;
            if(m < x) l = m;
            else r = m;
        }
        cnt += r - section[i].first ;
    }
    return cnt < k;
}

int main(){
    cin >> n >> k;
    rep(i,n){
        cin >> section[i].first >> section[i].second;
    }
    ll left = -1,right = INF + 1;
    while(right - left > 1){
        ll mid = (left + right)/2;
        if(ok(mid)) left = mid;
        else right = mid;
    }
    cout << left << endl;
    return 0;
}
0