hkshakib

Untitled

Mar 17th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. priority_queue<pair<int,int> , vector<pair<int,int> >, greater<pair<int,int> > > pq;
  6. vector<pair<int,int>>pq1;
  7. map<int,int>mp;
  8. string s;
  9. int num,time;
  10. while(cin>>s && s[0]!='#')
  11. {
  12. cin>>num>>time;
  13. pq.push({time,num});
  14. mp[num]=time;
  15. }
  16. int k;
  17. cin>>k;
  18. int kk=k;
  19. pair<int, int> top = pq.top();
  20. while(k--)
  21. {
  22. pq1.push_back({top.first,top.second});
  23. int y = top.second;
  24. top.first +=mp[y];
  25. }
  26. for(int i=0; i<kk; ++i)
  27. {
  28. cout<<pq1[i].second<<endl;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment