Submission #924140

#TimeUsernameProblemLanguageResultExecution timeMemory
924140vjudge1Advertisement 2 (JOI23_ho_t2)C++17
59 / 100
2085 ms11360 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

#define fst first 
#define snd second
#define pb push_back
#define forn(i,a,b) for(int i = a; i < b; i++)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define dbg(v) cout<<"Line("<<__LINE__<<"): "<<#v<<" = "<<v<<'\n';
#define pi pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset;

int main(){FIN;
	ll n; cin>>n;
	vector< pair<ll,ll> > person(n);
	set< pair<ll,ll> > priority;
	forn(i,0,n)	cin>>person[i].fst>>person[i].snd, priority.insert({person[i].snd,person[i].fst});
	sort(ALL(person));
	ll res = 0;

	while(!priority.empty()){
		auto it = --priority.end();

		auto newIt = priority.begin();
		while(newIt!=priority.end()){
			auto nnewIt = newIt;
			nnewIt++;
			if(it!=newIt){
				if(abs((*it).snd-(*newIt).snd)<=(*it).fst-(*newIt).fst){
					priority.erase(newIt);
				}
			}
			newIt = nnewIt;
			
		}
		priority.erase(it);
		//cout<<SZ(priority)<<'\n';
		res++;
	}
	cout<<res<<'\n';
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...