# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146972 | gs14004 | Lightning Rod (NOI18_lightningrod) | C++17 | 2059 ms | 229448 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>
#define sz(v) ((int)(v).size())
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int MAXN = 10000005;
int n;
pi a[MAXN];
vector<int> stk;
bool in(int x, int y){
return a[x].first - a[x].second <= a[y].first - a[y].second &&
a[y].first + a[y].second <= a[x].first + a[x].second;
}
int main(){
scanf("%d",&n);
for(int i=0; i<n; i++){
scanf("%d %d",&a[i].first,&a[i].second);
if(stk.empty()) stk.push_back(i);
else{
if(in(stk.back(), i)) continue;
while(!stk.empty() && in(i, stk.back())) stk.pop_back();
stk.push_back(i);
}
}
printf("%d\n", sz(stk));
}
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... |