제출 #924105

#제출 시각아이디문제언어결과실행 시간메모리
924105Edu175Advertisement 2 (JOI23_ho_t2)C++17
10 / 100
117 ms17864 KiB
#include <bits/stdc++.h> #define pb push_back #define fst first #define snd second #define fore(i,a,b) for(ll i=a,ggdem=b;i<ggdem;++i) #define SZ(x) ((int)x.size()) #define ALL(x) x.begin(),x.end() #define mset(a,v) memset((a),(v),sizeof(a)) #define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define imp(v) for(auto edu:v)cout<<edu.fst<<","<<edu.snd<<" "; cout<<"\n" using namespace std; typedef long long ll; typedef pair<ll,ll> ii; int main(){FIN; ll n; cin>>n; vector<ii>a(n),b; fore(i,0,n)cin>>a[i].fst>>a[i].snd; sort(ALL(a)); fore(i,0,n){ if(SZ(b)&&b.back().fst==a[i].fst)b.pop_back(); b.pb(a[i]); } // cout<<SZ(b)<<"\n"; //sb1 a=b; n=SZ(a); ll p=0; fore(i,0,n)if(a[i].snd>a[p].snd)p=i; // imp(a); // cout<<p<<"\n"; ll e=a[p].snd,d=a[p].fst; ll res=1; // cout<<"left\n"; for(ll i=p-1;i>=0;i--){ e-=abs(d-a[i].fst),d=a[i].fst; // cout<<i<<": "<<e<<" "<<a[i].snd<<"\n"; if(e<a[i].snd)res++,e=a[i].snd; } e=a[p].snd,d=a[p].fst; // cout<<"right\n"; fore(i,p+1,n){ e-=abs(d-a[i].fst),d=a[i].fst; // cout<<i<<": "<<e<<" "<<a[i].snd<<"\n"; if(e<a[i].snd)res++,e=a[i].snd; } 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...