Submission #865350

#TimeUsernameProblemLanguageResultExecution timeMemory
865350Trisanu_DasLightning Rod (NOI18_lightningrod)C++17
Compilation error
0 ms0 KiB
#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 (stderr)

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);
      |         ^~~~~~~~~