链接
https://vjudge.net/problem/UVA-1203
题解
刷水题的时候1A的感觉真爽
这题就是优先队列
(不知道为啥最近我的uva上不去了qwq,只能用vjudge)
代码
#include <bits/stdc++.h>
#define maxn 100010
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
priority_queue< pr , vector<pr> , greater<pr> > pq;
ll K, add[maxn];
int main()
{
string s;
ll Q_num, Period;
pr x;
while(1)
{
cin>>s;
if(s=="#")break;
cin>>Q_num>>Period;
add[Q_num] = Period;
pq.emplace( make_pair(Period,Q_num) );
}
cin>>K;
while(K--)
{
x = pq.top(), pq.pop();
cout<<x.second<<endl;
pq.emplace( make_pair(x.first + add[x.second] , x.second) );
}
return 0;
}