Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>> > pq;
- vector<pair<int,int>>pq1;
- map<int,int>mp;
- string s;
- int num,time;
- while(cin>>s && s[0]!='#')
- {
- cin>>num>>time;
- pq.push({time,num});
- mp[num]=time;
- }
- int k;
- cin>>k;
- int kk=k;
- while(k--)
- {
- pq1.push_back({pq.top().first,pq.top().second});
- int y = pq.top().second;
- pair<int, int> Top;
- Top.first = pq.top().first + mp[y];
- Top.second = pq.top().second;
- pq.pop();
- pq.push(Top);
- }
- for(int i=0; i<kk; i++)
- {
- cout<<pq1[i].second<<endl;
- }
- }
Add Comment
Please, Sign In to add comment