제출 #1217079

#제출 시각아이디문제언어결과실행 시간메모리
1217079JuanJLAdvertisement 2 (JOI23_ho_t2)C++20
100 / 100
114 ms15956 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define fst first
#define snd second
#define pb push_back
#define SZ(x) (int) x.size()
#define ALL(x) x.begin(),x.end()
#define forn(i,a,b) for(int i = a; i<b; i++)
#define mset(a,v) memset(a,v,sizeof(a))
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> iset;

ostream& operator<<(ostream &os, pair<ll,ll> p ){
    return os<<"("<<p.fst<<" "<<p.snd<<")";
}

bool op(const pair<ll,ll> &a, const pair<ll,ll> &b){
    if(a.fst<b.fst) return true;
    if(a.fst>b.fst) return false;
    if(a.snd>b.snd) return true;
    return false;
}

int main(){FIN;
    ll n; cin>>n;
    vector<pair<ll,ll>> dat(n); forn(i,0,n) cin>>dat[i].fst>>dat[i].snd;

    vector<pair<ll,ll>> r(n); forn(i,0,n) r[i]={dat[i].fst-dat[i].snd,dat[i].fst+dat[i].snd};
    sort(ALL(r),op);

    ll last = -100;
    ll res = 0;
    forn(i,0,n){
        if(r[i].snd>last){
            //cout<<r[i].fst<<" "<<r[i].snd<<'\n';
            last=r[i].snd;
            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...