Submission #865364

#TimeUsernameProblemLanguageResultExecution timeMemory
865364Trisanu_DasLightning Rod (NOI18_lightningrod)C++17
66 / 100
2035 ms50412 KiB
#include <bits/stdc++.h> using namespace std; int dp[10000010], n, mx; stack<int> s; int main() { cin >> n; for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; if (i == 1) { mx = x + y; s.push(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'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...