結果

問題 No.817 Coin donation
ユーザー kyort0nkyort0n
提出日時 2019-04-19 21:28:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 779 bytes
コンパイル時間 1,687 ms
コンパイル使用メモリ 167,140 KB
実行使用メモリ 4,456 KB
最終ジャッジ日時 2023-10-23 23:19:41
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 5 ms
4,348 KB
testcase_07 AC 6 ms
4,348 KB
testcase_08 AC 20 ms
4,348 KB
testcase_09 AC 7 ms
4,348 KB
testcase_10 AC 27 ms
4,456 KB
testcase_11 AC 27 ms
4,456 KB
testcase_12 AC 27 ms
4,456 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,348 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;
    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