Contest Duration: - (local time) (180 minutes)

Submission #19392611

Source Code Expand

Copy
```//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define ld long double

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define rrep(i, a, b) for(int i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi(a,b,c,d) vector<vector<int>> a(b,vector<int>(c,d));
#define vvll(a,b,c,d) vector<vector<ll>> a(b,vector<ll>(c,d));

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define endl '\n'
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1000000007;
//const int MOD=998244353;
const ll INF = 1e18+1;
const int inf = 1e9+1;
const double PI = acos(-1);
int dx[8] = {1, 0, -1,  0,  1, 1, -1, -1};
int dy[8] = {0, 1,  0, -1, -1, 1,  1, -1};
bool range(int y, int x, int h, int w){
if(y < 0 || x < 0 || y >= h || x >= w) return false;
else return true;
}

const int MAX = 310000;

signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);

int n, k;
cin >> n >> k;
vll a(n), b(n);
rep(i, n) cin >> a[i] >> b[i];

priority_queue<pll, vpll, greater<pll>> use;
rep(i, n) use.push({a[i], b[i]});//終わる時間，追加時間

int cnt = 0;
ll cur = 0;

while(cnt < k){
auto[t, b] = use.top();
use.pop();
cur += t;
cnt++;
use.push({t+b, b});
}
cout << cur << endl;

return 0;
}```

#### Submission Info

Submission Time 2021-01-12 14:32:23+0900 C - Factory cumin C++ (GCC 9.2.1) 300 1946 Byte AC 47 ms 6824 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
Case Name Status Exec Time Memory
sample_01.txt AC 9 ms 3476 KB
sample_02.txt AC 7 ms 3536 KB
sample_03.txt AC 3 ms 3464 KB
subtask_1_1.txt AC 2 ms 3524 KB
subtask_1_10.txt AC 30 ms 5052 KB
subtask_1_11.txt AC 2 ms 3468 KB
subtask_1_12.txt AC 31 ms 6760 KB
subtask_1_13.txt AC 2 ms 3464 KB
subtask_1_14.txt AC 16 ms 4192 KB
subtask_1_15.txt AC 46 ms 6812 KB
subtask_1_16.txt AC 9 ms 3544 KB
subtask_1_17.txt AC 3 ms 3524 KB
subtask_1_18.txt AC 41 ms 6824 KB
subtask_1_2.txt AC 22 ms 3876 KB
subtask_1_3.txt AC 18 ms 4928 KB
subtask_1_4.txt AC 18 ms 3520 KB
subtask_1_5.txt AC 33 ms 6680 KB
subtask_1_6.txt AC 19 ms 3740 KB
subtask_1_7.txt AC 9 ms 3544 KB
subtask_1_8.txt AC 47 ms 6748 KB
subtask_1_9.txt AC 42 ms 6592 KB