Submission #1825644


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/



typedef long long ll;
int N, K;
ll A[101010], B[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i] >> B[i];

    min_priority_queue<pair<ll, int>> q;
    rep(i, 0, N) q.push({ A[i], i });

    ll ans = 0;
    rep(i, 0, K) {
        auto p = q.top(); q.pop();
        ans += p.first;
        q.push({ p.first + B[p.second], p.second });
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task C - Factory
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1547 Byte
Status AC
Exec Time 39 ms
Memory 3956 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 1 ms 256 KB
sample_02.txt AC 5 ms 256 KB
sample_03.txt AC 2 ms 256 KB
subtask_1_1.txt AC 1 ms 256 KB
subtask_1_10.txt AC 19 ms 2296 KB
subtask_1_11.txt AC 1 ms 256 KB
subtask_1_12.txt AC 22 ms 3956 KB
subtask_1_13.txt AC 1 ms 256 KB
subtask_1_14.txt AC 11 ms 1404 KB
subtask_1_15.txt AC 37 ms 3956 KB
subtask_1_16.txt AC 3 ms 256 KB
subtask_1_17.txt AC 2 ms 256 KB
subtask_1_18.txt AC 32 ms 3956 KB
subtask_1_2.txt AC 14 ms 768 KB
subtask_1_3.txt AC 13 ms 2168 KB
subtask_1_4.txt AC 10 ms 256 KB
subtask_1_5.txt AC 24 ms 3956 KB
subtask_1_6.txt AC 10 ms 512 KB
subtask_1_7.txt AC 6 ms 256 KB
subtask_1_8.txt AC 39 ms 3956 KB
subtask_1_9.txt AC 36 ms 3828 KB