# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
712096 | Pherokung | Lightning Rod (NOI18_lightningrod) | C++14 | 2033 ms | 158080 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;
#define MAXN 10000005
#define F first
#define S second
int n,x[MAXN],y[MAXN],rod[MAXN],ans=0;
deque<int> dq;
bool oper(pair<int,int> i,pair<int,int> j){
return i.F > j.F;
}
int main(){
scanf("%d",&n);
ans = n;
for(int i=1;i<=n;i++){
scanf("%d%d",&x[i],&y[i]);
rod[i] = 1;
}
for(int i=1;i<=n;i++){
while(!dq.empty()){
int p = dq.front();
if(y[i] - x[i] >= y[p] - x[p]){
if(rod[p] == 1){
rod[p] = 0;
ans--;
}
dq.pop_front();
}
else break;
}
dq.push_front(i);
}
while(!dq.empty()) dq.pop_front();
for(int i=n;i>=1;i--){
while(!dq.empty()){
int p = dq.front();
if(y[i] + x[i] >= y[p] + x[p]){
if(rod[p] == 1){
rod[p] = 0;
ans--;
}
dq.pop_front();
}
else break;
}
dq.push_front(i);
}
printf("%d",ans);
}
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... |