이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |