Submission #979132

#TimeUsernameProblemLanguageResultExecution timeMemory
979132MilosMilutinovicLightning Rod (NOI18_lightningrod)C++14
66 / 100
2099 ms246968 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> x(n); vector<int> y(n); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; x[i] = a - b; y[i] = a + b; } vector<int> order(n); iota(order.begin(), order.end(), 0); sort(order.begin(), order.end(), [&](int i, int j) { if (x[i] != x[j]) { return x[i] < x[j]; } else { return y[i] > y[j]; } }); auto xs = y; sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); int ans = 0, mx = -1; for (int i : order) { int v = (int) (lower_bound(xs.begin(), xs.end(), y[i]) - xs.begin()); if (mx < v) { ans += 1; mx = v; } } cout << ans << '\n'; return 0; }
#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...