fork(5) download
  1. #include <iostream>
  2. #include <queue>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. const int NO_X = 2e9;
  8.  
  9. const string REMOVE = "removeMin";
  10. const string GET = "getMin";
  11. const string INSERT = "insert";
  12.  
  13. int main() {
  14. ios_base::sync_with_stdio(false);
  15. cin.tie(0);
  16.  
  17. int n;
  18. cin >> n;
  19.  
  20. vector<pair<string, int> > ans;
  21. priority_queue<int> q;
  22.  
  23. for (int i = 0; i < n; i++) {
  24. string s;
  25. cin >> s;
  26. if (s == INSERT) {
  27. int x;
  28. cin >> x;
  29. q.push(-x);
  30. ans.push_back(make_pair(s, x));
  31. } else if (s == GET) {
  32. int x;
  33. cin >> x;
  34. while (!q.empty() && -q.top() < x) {
  35. q.pop();
  36. ans.push_back(make_pair(REMOVE, NO_X));
  37. }
  38. if (q.empty() || -q.top() > x) {
  39. q.push(-x);
  40. ans.push_back(make_pair(INSERT, x));
  41. }
  42. ans.push_back(make_pair(s, x));
  43. } else { // s == REMOVE
  44. if (q.empty()) {
  45. ans.push_back(make_pair(INSERT, 0));
  46. } else {
  47. q.pop();
  48. }
  49. ans.push_back(make_pair(s, NO_X));
  50. }
  51. }
  52.  
  53. cout << ans.size() << "\n";
  54. for (auto& p : ans) {
  55. cout << p.first;
  56. if (p.second != NO_X) {
  57. cout << " " << p.second;
  58. }
  59. cout << "\n";
  60. }
  61.  
  62.  
  63. return 0;
  64. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:54:16: error: ISO C++ forbids declaration of 'p' with no type [-fpermissive]
     for (auto& p : ans) {
                ^
prog.cpp:54:20: warning: range-based 'for' loops only available with -std=c++11 or -std=gnu++11
     for (auto& p : ans) {
                    ^
prog.cpp:55:19: error: request for member 'first' in 'p', which is of non-class type 'int'
         cout << p.first;
                   ^
prog.cpp:56:15: error: request for member 'second' in 'p', which is of non-class type 'int'
         if (p.second != NO_X) {
               ^
prog.cpp:57:30: error: request for member 'second' in 'p', which is of non-class type 'int'
             cout << " " << p.second;
                              ^
stdout
Standard output is empty