제출 #1049549

#제출 시각아이디문제언어결과실행 시간메모리
1049549ymmAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
99 ms22984 KiB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 500'010;
pll a[N];
int n;

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	// 1 - 1i
	// (x + y) + (-x + y)i
	cin >> n;
	Loop (i,0,n) {
		ll x, y;
		cin >> x >> y;
		a[i] = {
			x + y,
			-x + y,
		};
	}
	sort(a, a+n);
	vector<ll> vec;
	Loop (i,0,n) {
		while (vec.size() && vec.back() <= a[i].second)
			vec.pop_back();
		vec.push_back(a[i].second);
	}
	cout << vec.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...