Submission #1300595

#TimeUsernameProblemLanguageResultExecution timeMemory
1300595danglayloi1Lightning Rod (NOI18_lightningrod)C++20
0 / 100
373 ms79728 KiB
#include <bits/stdc++.h>
#define ii pair<int, int>
#define fi first
#define se second
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = long long;
const ll mod=1e9+7;
const int nx=1e7+5;
int n, ans=0, cur=-1, x, y;
stack<ii> st;
ii p;
bool ok;
void fastscan(int &x)
{
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-')
    {
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
        x *=-1;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    while(n--)
    {
        fastscan(x);
        fastscan(y);
        ok=1;
        while(st.size())
        {
            p=st.top();
            if(x-p.fi<=p.se-y)
            {
                ok=0;
                break;
            }
            if(x-p.fi<=y-p.se)
                st.pop();
            else break;
        }
        if(ok) st.push({x, y});
    }
    cout<<st.size();
}

Compilation message (stderr)

Main.cpp: In function 'void fastscan(int&)':
Main.cpp:17:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |     register int c;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...