Submission #942463

#TimeUsernameProblemLanguageResultExecution timeMemory
942463dsyzAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
124 ms24800 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll N;
	cin>>N;
	pair<ll,ll> arr[N];
	for(ll i = 0;i < N;i++){
		cin>>arr[i].first>>arr[i].second;
	}
	sort(arr,arr + N);
	stack<pair<ll,ll> > st;
	for(ll i = 0;i < N;i++){
		while(!st.empty() && abs(arr[i].first - st.top().first) <= arr[i].second - st.top().second){
			st.pop();
		}
		if(st.empty() || (abs(arr[i].first - st.top().first) > arr[i].second - st.top().second && abs(st.top().first - arr[i].first) > st.top().second - arr[i].second)){
			st.push(arr[i]);
		}
	}
	cout<<st.size()<<'\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...