Submission #17505835


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n, k;
    cin >> n >> k;
    priority_queue<P, vector<P>, greater<P>> pque;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        pque.push({a, b});
    }
    ll ans = 0;
    while(k--){
        P p = pque.top();
        pque.pop();
        ans += p.first;
        pque.push({p.first + p.second, p.second});
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task C - Factory
User bustle0309
Language C++ (GCC 9.2.1)
Score 300
Code Size 731 Byte
Status
Exec Time 83 ms
Memory 5364 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
× 3
× 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 8 ms 3472 KB
sample_02.txt 7 ms 3604 KB
sample_03.txt 2 ms 3600 KB
subtask_1_1.txt 2 ms 3596 KB
subtask_1_10.txt 37 ms 4216 KB
subtask_1_11.txt 3 ms 3500 KB
subtask_1_12.txt 64 ms 5312 KB
subtask_1_13.txt 2 ms 3436 KB
subtask_1_14.txt 25 ms 3756 KB
subtask_1_15.txt 74 ms 5120 KB
subtask_1_16.txt 5 ms 3576 KB
subtask_1_17.txt 2 ms 3500 KB
subtask_1_18.txt 74 ms 5364 KB
subtask_1_2.txt 21 ms 3720 KB
subtask_1_3.txt 38 ms 4316 KB
subtask_1_4.txt 17 ms 3600 KB
subtask_1_5.txt 64 ms 5364 KB
subtask_1_6.txt 17 ms 3620 KB
subtask_1_7.txt 12 ms 3428 KB
subtask_1_8.txt 83 ms 5364 KB
subtask_1_9.txt 72 ms 5256 KB