# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
313299 | kaplanbar | Lightning Rod (NOI18_lightningrod) | C++14 | 2091 ms | 85040 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using ll = long long;
constexpr int N = 1e7+1;
int n;
pair<int,int> a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++) {
cin >> a[i].first >> a[i].second;
}
vector<bool> v(n, 0);
int mx = -2e9;
for(int i = 0; i < n; i++) {
int val = a[i].first + a[i].second;
if(mx >= val) {
v[i] = 1;
}
else {
mx = val;
}
}
mx = -2e9;
for(int i = n - 1; i >= 0; i--) {
int val = a[i].second - a[i].first;
if(mx >= val) {
v[i] = 1;
}
else {
mx = val;
}
}
int ans = 0;
for(int i = 0; i < n; i++) ans += 1^v[i];
cout << ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |