Submission #19571861


Source Code Expand

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

typedef long long ll;
typedef pair<ll, ll> pll;

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

    priority_queue<pll, vector<pll>, greater<pll>> 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 610 Byte
Status AC
Exec Time 85 ms
Memory 5348 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 9 ms 3420 KB
sample_02.txt AC 8 ms 3532 KB
sample_03.txt AC 2 ms 3392 KB
subtask_1_1.txt AC 2 ms 3540 KB
subtask_1_10.txt AC 44 ms 4248 KB
subtask_1_11.txt AC 2 ms 3500 KB
subtask_1_12.txt AC 63 ms 5296 KB
subtask_1_13.txt AC 2 ms 3448 KB
subtask_1_14.txt AC 37 ms 3804 KB
subtask_1_15.txt AC 79 ms 5348 KB
subtask_1_16.txt AC 4 ms 3464 KB
subtask_1_17.txt AC 2 ms 3580 KB
subtask_1_18.txt AC 79 ms 5156 KB
subtask_1_2.txt AC 28 ms 3624 KB
subtask_1_3.txt AC 40 ms 4108 KB
subtask_1_4.txt AC 15 ms 3448 KB
subtask_1_5.txt AC 71 ms 5208 KB
subtask_1_6.txt AC 18 ms 3624 KB
subtask_1_7.txt AC 12 ms 3584 KB
subtask_1_8.txt AC 85 ms 5236 KB
subtask_1_9.txt AC 77 ms 5296 KB