Submission #183930

#TimeUsernameProblemLanguageResultExecution timeMemory
183930duttaditya18Lightning Rod (NOI18_lightningrod)C++17
66 / 100
2064 ms252856 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second int main(void) { ios_base::sync_with_stdio(0); cin.tie(NULL); int n; cin >> n; // x, y pair<int, int> p[n + 1]; for(int i = 1; i <= n; i++) cin >> p[i].fi >> p[i].se; int suf[n + 2] = {}; int prf[n + 2] = {}; prf[0] = INT_MIN; prf[n + 1] = INT_MIN; suf[0] = INT_MAX; suf[n + 1] = INT_MAX; for(int i = 1; i <= n; i++) prf[i] = max(prf[i - 1], p[i].fi + p[i].se); for(int i = n; i >= 1; i--) suf[i] = min(suf[i + 1], p[i].fi - p[i].se); int ans = n; for(int i = 1; i <= n; i++) ans -= ((p[i].fi + p[i].se <= prf[i - 1]) || (p[i].fi - p[i].se >= suf[i + 1])); cout << ans << 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...