# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
265315 | T0p_ | Lightning Rod (NOI18_lightningrod) | C++14 | 0 ms | 0 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;
pair<int, int> arr[10000005];
int main()
{
int n, now = 0;
scanf(" %d",&n);
while(n--)
{
int x, y;
scanf(" %d %d",&x,&y);
if(now == 0) arr[++now] = {x, y};
else
{
int h = arr[now].second - x + arr[now].first;
if(h >= y) continue ;
while(!stk.empty())
{
int h = y - x + arr[now].first;
if(h >= arr[now].second) now--;
else break ;
}
arr[++now] = {x, y};
}
}
printf("%d\n",now);
return 0;
}