# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
161429 | Berted | Lightning Rod (NOI18_lightningrod) | C++14 | 2070 ms | 172080 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 <iostream>
#include <stack>
#include <cstdio>
#define pii pair<int,int>
#define fst first
#define snd second
using namespace std;
stack<pii> s;
int n,a,b;
int main()
{
scanf("%d",&n);
for (int i=0;i<n;i++)
{
scanf("%d %d",&a,&b);
if (s.empty()) {s.push({a,b});}
else
{
if (a - s.top().fst > s.top().snd - b)
{
while (s.size())
{
if (a - s.top().fst <= b - s.top().snd) {s.pop();}
else {break;}
}
s.push({a,b});
}
}
//cout<<i<<" "<<s.size()<<"\n";
}
printf("%d\n",(int)s.size());
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... |