Submission #3717716


Source Code Expand

Copy
//cod2017th_c.cpp
//Sun Dec  2 20:36:35 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;

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

	priority_queue<P, vector<P>, greater<P>> pq2; //小さい順 
	for (int i=0;i<n;i++){
		ll a,b;
		cin >> a >> b;
		pq2.push(make_pair(a,b));
	}

	ll num = 0;
	ll ans = 0;
	while (num<k){
		P p = pq2.top();
		pq2.pop();
		ans += p.first;
		pq2.push(make_pair(p.first+p.second,p.second));
		num++;
	}



	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Submission Info

Submission Time
Task C - Factory
User hornistyf
Language C++14 (GCC 5.4.1)
Score 300
Code Size 738 Byte
Status AC
Exec Time 99 ms
Memory 2420 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 4 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 40 ms 1400 KB
subtask_1_11.txt AC 1 ms 256 KB
subtask_1_12.txt AC 70 ms 2420 KB
subtask_1_13.txt AC 1 ms 256 KB
subtask_1_14.txt AC 25 ms 892 KB
subtask_1_15.txt AC 87 ms 2420 KB
subtask_1_16.txt AC 3 ms 256 KB
subtask_1_17.txt AC 2 ms 256 KB
subtask_1_18.txt AC 94 ms 2420 KB
subtask_1_2.txt AC 19 ms 640 KB
subtask_1_3.txt AC 41 ms 1400 KB
subtask_1_4.txt AC 10 ms 256 KB
subtask_1_5.txt AC 83 ms 2420 KB
subtask_1_6.txt AC 13 ms 512 KB
subtask_1_7.txt AC 6 ms 256 KB
subtask_1_8.txt AC 99 ms 2420 KB
subtask_1_9.txt AC 87 ms 2420 KB