이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pl = pair<ll,ll>;
#define pb push_back
#define form(m,it) for(auto it=m.begin(); it!=m.end(); it++)
#define forp(i,a,b) for(ll i=a; i<=b; i++)
#define forn(i,a,b) for(ll i=a; i>=b; i--)
#define newl '\n'
#define ff first
#define ss second
const ll mod = 1000000007;
int besthub(int r, int l, int x[], ll b){
ll ans=0,n,m,cnt,temp;
forp(i,0,r-1){
n=i-1,m=i+1;
cnt=1,temp=0;
while(temp<=b){
if(n<0 && m>r-1){
break;
} else if(n>=0 && m>r-1){
if(temp+(x[i]-x[n])<=b){
temp+=(x[i]-x[n]);
n--;
cnt++;
} else {
break;
}
} else if(m<=r-1 && n<0){
if(temp+(x[m]-x[i])<=b){
temp+=(x[m]-x[i]);
m++;
cnt++;
} else {
break;
}
} else {
if(x[m]-x[i]<x[i]-x[n] && temp+(x[m]-x[i])<=b){
temp+=(x[m]-x[i]);
m++;
cnt++;
} else if(temp+(x[i]-x[n])<=b){
temp+=(x[i]-x[n]);
n--;
cnt++;
} else {
break;
}
}
}
ans=max(ans,cnt);
}
return ans;
}
# | 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... |