Submission #43365543


Source Code Expand

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;


int64_t solve(int N, int64_t K, const std::vector<int64_t> &a, const std::vector<int64_t> &b) {
    long int current_pill = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> schedules;

    REP(i, N){
        auto pair = make_pair(a[i], b[i]);
        current_pill += pair.second;
        schedules.push(pair);
    }

    int last_date = 0;
    while (current_pill > K) {
        auto top = schedules.top();
        schedules.pop();

        current_pill -= top.second;
        last_date = top.first;
    }

    return last_date + 1;
}

// generated by oj-template v4.8.1 (https://github.com/online-judge-tools/template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N;
    int64_t K;
    std::cin >> N;
    std::vector<int64_t> a(N), b(N);
    std::cin >> K;
    REP (i, N) {
        std::cin >> a[i] >> b[i];
    }
    auto ans = solve(N, K, a, b);
    std::cout << ans << '\n';
    return 0;
}

Submission Info

Submission Time
Task C - Medicine
User maureen
Language C++ (GCC 9.2.1)
Score 350
Code Size 1340 Byte
Status AC
Exec Time 98 ms
Memory 12028 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 30
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_srnd_00.txt, 01_srnd_01.txt, 01_srnd_02.txt, 01_srnd_03.txt, 01_srnd_04.txt, 01_srnd_05.txt, 02_rnd_00.txt, 02_rnd_01.txt, 02_rnd_02.txt, 02_rnd_03.txt, 02_rnd_04.txt, 02_rnd_05.txt, 03_minmax_00.txt, 03_minmax_01.txt, 03_minmax_02.txt, 03_minmax_03.txt, 03_minmax_04.txt, 03_minmax_05.txt, 03_minmax_06.txt, 03_minmax_07.txt, 04_hand_00.txt, 04_hand_01.txt, 04_hand_02.txt, 04_hand_03.txt, 04_hand_04.txt, 04_hand_05.txt, 04_hand_06.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 7 ms 3456 KiB
00_sample_01.txt AC 2 ms 3472 KiB
00_sample_02.txt AC 2 ms 3452 KiB
01_srnd_00.txt AC 2 ms 3356 KiB
01_srnd_01.txt AC 2 ms 3460 KiB
01_srnd_02.txt AC 2 ms 3532 KiB
01_srnd_03.txt AC 2 ms 3428 KiB
01_srnd_04.txt AC 2 ms 3524 KiB
01_srnd_05.txt AC 2 ms 3468 KiB
02_rnd_00.txt AC 98 ms 11904 KiB
02_rnd_01.txt AC 97 ms 11976 KiB
02_rnd_02.txt AC 98 ms 11952 KiB
02_rnd_03.txt AC 68 ms 11948 KiB
02_rnd_04.txt AC 81 ms 12028 KiB
02_rnd_05.txt AC 67 ms 11900 KiB
03_minmax_00.txt AC 52 ms 11984 KiB
03_minmax_01.txt AC 63 ms 11980 KiB
03_minmax_02.txt AC 66 ms 11880 KiB
03_minmax_03.txt AC 78 ms 11984 KiB
03_minmax_04.txt AC 52 ms 11888 KiB
03_minmax_05.txt AC 63 ms 12020 KiB
03_minmax_06.txt AC 64 ms 11952 KiB
03_minmax_07.txt AC 78 ms 11904 KiB
04_hand_00.txt AC 4 ms 3460 KiB
04_hand_01.txt AC 2 ms 3456 KiB
04_hand_02.txt AC 61 ms 11956 KiB
04_hand_03.txt AC 65 ms 11980 KiB
04_hand_04.txt AC 90 ms 11980 KiB
04_hand_05.txt AC 79 ms 11968 KiB
04_hand_06.txt AC 78 ms 12024 KiB