結果

問題 No.817 Coin donation
ユーザー polyomino_24polyomino_24
提出日時 2019-04-21 12:08:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 1,931 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 126,832 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 12:17:05
合計ジャッジ時間 2,692 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 AC 14 ms
6,944 KB
testcase_07 AC 17 ms
6,940 KB
testcase_08 AC 65 ms
6,940 KB
testcase_09 AC 20 ms
6,944 KB
testcase_10 AC 89 ms
6,940 KB
testcase_11 AC 91 ms
6,940 KB
testcase_12 AC 90 ms
6,944 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, map<S, T> mp) {
    for (auto x : mp) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main() {
    int n, k;
    cin >> n >> k;
    vector<pii> d(n);
    rep(i, n) cin >> d[i].first >> d[i].second;
    int l = 0;
    int r = 1e9 + 2;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        ll cnt = 0;
        rep(i, n) {
            if (d[i].first > mid) continue;
            if (d[i].second >= mid)
                cnt += mid - d[i].first + 1;
            else
                cnt += d[i].second - d[i].first + 1;
        }
        if (cnt >= k) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << r << endl;
}
0