28 lines
536 B
C++
28 lines
536 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
typedef pair<int, int> pii;
|
|
|
|
int main()
|
|
{
|
|
int N, K;
|
|
cin >> N >> K;
|
|
priority_queue<pii> pq;
|
|
vector<pair<string, int>> drugs(N);
|
|
for (int i = 0; i < N; i++)
|
|
{
|
|
cin >> drugs[i].first;
|
|
cin >> drugs[i].second;
|
|
pq.push({-drugs[i].second, -i});
|
|
}
|
|
|
|
while (K--)
|
|
{
|
|
int time = pq.top().first, i = pq.top().second;
|
|
cout << -time << " " << drugs[-i].first << endl;
|
|
pq.pop();
|
|
pq.push({time - drugs[-i].second, i});
|
|
}
|
|
return 0;
|
|
} |