Submission #865350

# Submission time Handle Problem Language Result Execution time Memory
865350 2023-10-24T07:39:17 Z Trisanu_Das Lightning Rod (NOI18_lightningrod) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int dp[10000005], n, mx;
stack<int> s;

int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    int x, y; cin >> x >> y;
    if(i == 0){
      mx = x + y;
      s.push_back(x - y);
    }else if(mx < x + y){
      while(!s.empty() && s.top() >= (x - y)) s.pop();
      s.push(x - y);
      mx = x + y;
    }
    cout << s.size() << '\n';
  }
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:13:9: error: 'class std::stack<int>' has no member named 'push_back'
   13 |       s.push_back(x - y);
      |         ^~~~~~~~~