# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
710123 | ToroTN | Lightning Rod (NOI18_lightningrod) | C++14 | 2021 ms | 262144 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 X first
#define Y second
int n,x[10000005],y[10000005],hsh[10000005],ans=0;
stack<pair<int,int> > stk;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]);
for(int i=1;i<=n;i++)
{
while(!stk.empty())
{
if(y[i]-x[i]>=stk.top().X)
{
stk.pop();
}else
{
break;
}
}
stk.push({y[i]-x[i],i});
}
while(!stk.empty())
{
++hsh[stk.top().Y];
stk.pop();
}
for(int i=n;i>=1;i--)
{
while(!stk.empty())
{
if(y[i]+x[i]>=stk.top().X)
{
stk.pop();
}else
{
break;
}
}
stk.push({y[i]+x[i],i});
}
while(!stk.empty())
{
++hsh[stk.top().Y];
stk.pop();
}
for(int i=1;i<=n;i++)if(hsh[i]==2)++ans;
printf("%d\n",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... |