Submission #1313511

#TimeUsernameProblemLanguageResultExecution timeMemory
1313511prunjuiceLightning Rod (NOI18_lightningrod)C++20
100 / 100
394 ms79692 KiB
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int, int>
#define mp make_pair

inline int readInt() {
    int x = 0;
    char ch = getchar();
    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(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, x, y;
	n = readInt();
	stack <pii> st;
	while (n--){
		x = readInt(), y = readInt();
		bool gay = true;
		while (!st.empty()){
			if (abs(x-st.top().first)<=st.top().second-y){
				gay = false;
				break;
			}
			if (abs(x-st.top().first)<=y-st.top().second){
				st.pop();
			}
			else{
				break;
			}
		}
		if (gay){
			st.push(mp(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...