# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
265322 | T0p_ | Lightning Rod (NOI18_lightningrod) | C++14 | 714 ms | 192028 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;
stack<pair<int, int>> stk;
int fi()
{
int ret = 0;
while(true)
{
char c = getchar_unlocked();
if('0' <= c && c <= '9')
{
ret *= 10;
ret += (c-'0');
}
else return ret;
}
}
int main()
{
int n = fi();
while(n--)
{
int x = fi(), y = fi();
if(stk.empty()) stk.push({x, y});
else
{
int h = stk.top().second - x + stk.top().first;
if(h >= y) continue ;
while(!stk.empty())
{
int h = y - x + stk.top().first;
if(h >= stk.top().second) stk.pop();
else break ;
}
stk.push({x, y});
}
}
printf("%d\n",stk.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... |