Submission #756518

#TimeUsernameProblemLanguageResultExecution timeMemory
756518michaoAdvertisement 2 (JOI23_ho_t2)C++14
59 / 100
2048 ms5380 KiB
#include <bits/stdc++.h> #define int long long #define mp make_pair #define pb push_back #define ld long double #define pii pair<int,int> #define sz(x) (int)x.size() #define piii pair<pii,pii> #define precise cout<<fixed<<setprecision(10) #define st first #define nd second #define ins insert #define vi vector<int> #define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) using namespace std; const int MAX=5e5+5; int x[MAX],e[MAX]; bool cmp(int i,int j){ if (e[i]!=e[j])return e[i]>e[j]; return x[i]<x[j]; } bool O[MAX]; bool check(int i,int j){ return e[i]-e[j]>=abs(x[i]-x[j]); } int32_t main() { BOOST; int n; cin>>n; vi pom; for (int i=1;i<=n;i++)pom.pb(i); for (int i=1;i<=n;i++)cin>>x[i]>>e[i]; sort(pom.begin(),pom.end(),cmp); int ans=0; for (auto it:pom){ if (O[it])continue; O[it]=true; ans++; for (int i=1;i<=n;i++){ if (i==it)continue; if (check(it,i))O[i]=true; } } cout<<ans; 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...