結果

問題 No.817 Coin donation
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-04-22 10:32:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,152 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 74,272 KB
実行使用メモリ 10,784 KB
最終ジャッジ日時 2024-04-18 02:18:39
合計ジャッジ時間 4,517 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 79 ms
5,376 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    int K, N;
    cin >> N >> K;
    vector<P> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i].first >> A[i].second;
    }
    int left = 0, right = INF;
    while (left < right - 1) {
        int mid = (left + right) / 2, cnt = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i].first > mid) continue;
            if (A[i].second > mid) {
                cnt += mid - A[i].first + 1;
            }
            else {
                cnt += A[i].second - A[i].first + 1;
            }
        }
        if (cnt >= K) {
            right = mid;
        }
        else {
            left = mid;
        }
    }
    cout << right << endl;
    getchar(); getchar();
    return 0;
}
0