Submission #1300596

#TimeUsernameProblemLanguageResultExecution timeMemory
1300596danglayloi1Lightning Rod (NOI18_lightningrod)C++20
0 / 100
202 ms80724 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;
static const int BUF_SIZE = 1 << 20;
char buf[BUF_SIZE];
int bi = BUF_SIZE, bn = BUF_SIZE;
inline char readCharFast() {
    if (bi >= bn) {
        bn = fread(buf, 1, BUF_SIZE, stdin);
        bi = 0;
        if (bn == 0) return 0;
    }
    return buf[bi++];
}
inline bool fastReadInt(int &x) {
    char c;
    do c = readCharFast(); while (c <= ' ' && c != 0);
    if (!c) return false;

    int sign = 1;
    if (c == '-') {
        sign = -1;
        c = readCharFast();
    }

    int val = c - '0';
    while (1) {
        c = readCharFast();
        if (c < '0' || c > '9') break;
        val = val * 10 + (c - '0');
    }

    x = val * sign;
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    while(n--)
    {
        fastReadInt(x);
        fastReadInt(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();
}
#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...