Submission #909407

#TimeUsernameProblemLanguageResultExecution timeMemory
909407LOLOLOLightning Rod (NOI18_lightningrod)C++17
0 / 100
1253 ms262144 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long ll; typedef pair<ll, ll> pa; const ll N = 1e6 + 1; const ll MOD = 1e9 + 7; const ll INF = 1e12; int pr[N], suff[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector <pair <int, int>> v; for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; v.push_back({x, y}); } pr[0] = v[0].fi - v[0].se; for (int i = 1; i < n; i++) { pr[i] = max(pr[i - 1], v[i].fi + v[i].se); } suff[n - 1] = v[n - 1].fi + v[n - 1].se; for (int i = n - 2; i >= 0; i--) { suff[i] = min(suff[i + 1], v[i].fi - v[i].se); } int cnt = 0; if (suff[1] > v[0].fi - v[0].se) cnt++; if (pr[n - 2] < v[n - 1].fi + v[n - 1].se) cnt++; for (int i = 1; i < n - 1; i++) { if (suff[i + 1] > v[i].fi - v[i].se && pr[i - 1] < v[i].fi + v[i].se) { cnt++; } } cout << cnt << '\n'; return 0; } // x(i) - x(j) <= y(i) - y(j) // x(i) - y(i) <= x(j) - y(j) // x(j) - x(i) <= y(i) - y(j) // x(j) + y(j) <= x(i) + y(i)
#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...