제출 #1136751

#제출 시각아이디문제언어결과실행 시간메모리
1136751nuutsnoyntonAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
374 ms16360 KiB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using pll = pair < ll, ll > ;
int main() {
	ll r, x, y, i, can, X, Y, lo, hi, mid, n, j, ans, t, e;
	
	cin >> n;
	
	vector < pair < ll, ll > > vp;
	
	for (i = 1; i<= n; i ++) {
		cin >> x >> y;
		vp.push_back({x, y});
	}
	stack < pll > S;
	sort(vp.rbegin(), vp.rend());
	
	for (i =0; i < vp.size(); i ++) {
		x = vp[i].first;
		y = vp[i].second;
		while(!S.empty()) {
			X = S.top().first;
			Y = S.top().second;
			if ( abs(x - X) <= y - Y) S.pop();
			else break;
		}
		if ( S.empty()) {
			S.push({x, y});
		}
		else {
			X = S.top().first;
			Y = S.top().second;
			if ( abs(x - X) > Y - y){
				S.push({x, y});
			}
		}
	}
	cout << S.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...