Submission #19571849


Source Code Expand

Copy
#include <iostream>
#include <queue>
#include <utility>
using namespace std;

typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;

    priority_queue<pair<ll, ll>> pq;
    for(int i = 0; i < n; ++i) {
        ll a, b;
        cin >> a >> b;
        pq.push(make_pair(-a, -b));
    }

    long long ans = 0;
    for(int i = 0; i < k; ++i) {
        pair<ll, ll> p = pq.top();
        pq.pop();
        ans += -p.first;
        p.first += p.second;
        pq.push(p);
    }

    cout << ans << endl;
}

Submission Info

Submission Time
Task C - Factory
User shamio
Language C++ (GCC 9.2.1)
Score 300
Code Size 545 Byte
Status AC
Exec Time 86 ms
Memory 5376 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 21
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt AC 6 ms 3560 KB
sample_02.txt AC 8 ms 3560 KB
sample_03.txt AC 3 ms 3636 KB
subtask_1_1.txt AC 2 ms 3604 KB
subtask_1_10.txt AC 47 ms 4256 KB
subtask_1_11.txt AC 3 ms 3500 KB
subtask_1_12.txt AC 67 ms 5376 KB
subtask_1_13.txt AC 2 ms 3476 KB
subtask_1_14.txt AC 34 ms 3760 KB
subtask_1_15.txt AC 80 ms 5284 KB
subtask_1_16.txt AC 5 ms 3428 KB
subtask_1_17.txt AC 3 ms 3504 KB
subtask_1_18.txt AC 82 ms 5228 KB
subtask_1_2.txt AC 29 ms 3732 KB
subtask_1_3.txt AC 43 ms 4228 KB
subtask_1_4.txt AC 16 ms 3632 KB
subtask_1_5.txt AC 73 ms 5320 KB
subtask_1_6.txt AC 24 ms 3708 KB
subtask_1_7.txt AC 12 ms 3564 KB
subtask_1_8.txt AC 86 ms 5196 KB
subtask_1_9.txt AC 80 ms 5248 KB