Submission #1135383

#TimeUsernameProblemLanguageResultExecution timeMemory
1135383adkjtLightning Rod (NOI18_lightningrod)C++20
100 / 100
389 ms79832 KiB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define f first
#define s second
stack<pii> st;
int x,y,n;
int readInt()
{
    int x = 0;
    char ch = getchar_unlocked();
    while (ch < '0' || ch > '9') ch = getchar_unlocked();
    while (ch >= '0' && ch <= '9'){
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar_unlocked();
	}
    return x;
}
int main()
{

    n = readInt();
    for(int i=1;i<=n;i++)
    {
        x = readInt(),y = readInt();
        while(!st.empty()&&x-st.top().f<=y-st.top().s) st.pop();
        if(!st.empty()&&x-st.top().f<=st.top().s-y) continue;
        st.push({x,y});
    }
    printf("%d",(int)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...