Submission #1093092

#TimeUsernameProblemLanguageResultExecution timeMemory
1093092AbitoAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
451 ms49748 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=5e5+5;
pair<int,int> a[N];
int n;
bool b[N];
map<int,int> mp;
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i].F>>a[i].S,mp[a[i].F]=max(mp[a[i].F],a[i].S);
	n=0;
	for (auto u:mp) n++,a[n]=u;
	sort(a+1,a+1+n);
	int mx=LLONG_MIN;
	for (int i=1;i<=n;i++){
		if (a[i].F+a[i].S<=mx) b[i]=1;
		mx=max(mx,a[i].S+a[i].F);
	}
	mx=LLONG_MIN;
	for (int i=n;i;i--){
		if (a[i].S-a[i].F<=mx) b[i]=1;
		mx=max(mx,a[i].S-a[i].F);
	}
	int ans=0;
	for (int i=1;i<=n;i++) if (!b[i]) ans++;
	cout<<ans<<endl;
	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...