結果

問題 No.817 Coin donation
ユーザー kyort0nkyort0n
提出日時 2019-04-19 21:30:00
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 1,419 ms
使用メモリ 4,180 KB
最終ジャッジ日時 2022-11-22 06:06:16
合計ジャッジ時間 2,672 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,464 KB
testcase_01 AC 1 ms
3,500 KB
testcase_02 AC 2 ms
3,528 KB
testcase_03 AC 1 ms
3,404 KB
testcase_04 AC 1 ms
3,548 KB
testcase_05 AC 2 ms
3,432 KB
testcase_06 AC 5 ms
3,560 KB
testcase_07 AC 5 ms
3,600 KB
testcase_08 AC 17 ms
4,004 KB
testcase_09 AC 6 ms
3,608 KB
testcase_10 AC 25 ms
4,176 KB
testcase_11 AC 24 ms
4,176 KB
testcase_12 AC 25 ms
4,180 KB
testcase_13 AC 2 ms
3,464 KB
testcase_14 AC 1 ms
3,464 KB
testcase_15 AC 1 ms
3,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[100500];
    int B[100500];
    for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];
    int ok = INF;
    int ng = 0;
    while(ok - ng > 1) {
        int mid = (ok + ng) / 2;
        int now = 0;
        for(int i = 1; i <= N; i++) {
            int NEW = min(B[i], mid) - A[i] + 1;
            now += max(0, NEW);
            if(now >= K) break;
        }
        if(now >= K) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}
0