Submission #496805

#TimeUsernameProblemLanguageResultExecution timeMemory
496805SirCovidThe19thLightning Rod (NOI18_lightningrod)C++17
66 / 100
2081 ms231916 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, x, y) for (int i = x; i < y; i++) #define pii pair<int, int> #define f first #define s second int main(){ int n; cin >> n; bool covered[n] = {}; pii A[n]; set<pii> S; FOR(i, 0, n){ cin >> A[i].f >> A[i].s; while (!S.empty() and prev(S.end())->f >= A[i].f - A[i].s){ covered[prev(S.end())->s] = 1; S.erase(prev(S.end())); } S.insert({A[i].f - A[i].s, i}); } S.clear(); for (int i = n - 1; ~i; i--) if (!covered[i]){ while (!S.empty() and S.begin()->f <= A[i].f + A[i].s){ covered[S.begin()->s] = 1; S.erase(S.begin()); } S.insert({A[i].f + A[i].s, i}); } cout<<n - accumulate(covered, covered + n, 0)<<endl; }
#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...