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;
- pair<int, int> top = pq.top();
- while(k--)
- {
- pq1.push_back({top.first,top.second});
- int y = top.second;
- top.first +=mp[y];
- }
- for(int i=0; i<kk; ++i)
- {
- cout<<pq1[i].second<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment