# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
919716 | AnasAAF | Advertisement 2 (JOI23_ho_t2) | C++14 | 2009 ms | 8272 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define float double
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;cin>>n;
vector<pair<ll, ll>>v(n);
vector<pair<ll, pair<ll, ll>>>vp(n);
for(int i=0;i<n;i++){
ll a, b;cin>>a>>b;
v[i] = {a, b};
vp[i] = {b, {a, i}};
}
sort(vp.rbegin(), vp.rend());
vector<int>vis(n+1);
int ans(0);
queue<int>q;
for(int i=0;i<n;i++){
int a = vp[i].second.first, b = vp[i].first, ind = vp[i].second.second;
if(!vis[ind]){
ans++;
q.push(ind);
}
while(!q.empty()){
int in = q.front();
int x = v[in].first, y=v[in].second;
q.pop();
for(int j=0;j<n;j++){
if(vis[j])continue;
int m = v[j].first, n=v[j].second;
if(abs(x-m)<=y-n){
q.push(j);
vis[j]=1;
}
}
}
}
cout<<ans<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |