fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <cstring>
  6. #include <map>
  7. #include <queue>
  8. #include <sstream>
  9. #include <functional>
  10.  
  11. using namespace std;
  12.  
  13. #define F(a,b) for(int a=0;a<b;++a)
  14. typedef long long LL;
  15.  
  16. typedef pair<int,int>P;
  17. int main(){
  18. string s;
  19. stringstream ss;
  20. priority_queue<P,vector<P>,greater<P> >p;
  21. map<int,int> m;
  22. while(getline(cin,s)){
  23. ss << s;
  24. string a; ss >> a;
  25. if(a == "#") break;
  26. int b,c; ss >> b >> c;
  27. m[b] = c;
  28. p.push(P(c,b));
  29. ss.clear();
  30. }
  31. int t; cin >> t;
  32. while(t--){
  33. P now = p.top(); p.pop();
  34. cout << now.second << "\n";
  35. p.push(P(m[now.second] + now.first,now.second));
  36. }
  37. }
Runtime error #stdin #stdout 0s 3300KB
stdin
Standard input is empty
stdout
Standard output is empty