Submission #423875

#TimeUsernameProblemLanguageResultExecution timeMemory
423875faresbasbsLightning Rod (NOI18_lightningrod)C++14
100 / 100
633 ms262144 KiB
#include <bits/stdc++.h>
using namespace std;
inline 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 X[10000000], Y[10000000];

int main(){
	int N = readInt();
	stack<pair<int,int>> st;
	for(int i = 0; i < N; i++) {
		X[i] = readInt();
		Y[i] = readInt();
		while(true){
			if(st.size() && X[i]-st.top().first <= Y[i]-st.top().second){
				st.pop();
			}else if(st.size() && st.top().first-X[i] >= Y[i]-st.top().second){
				break;
			}else{
				st.push({X[i],Y[i]});
				break;
			}
		}
	}
	cout << st.size() << endl;
}
#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...