제출 #491286

#제출 시각아이디문제언어결과실행 시간메모리
491286niloyroot쌀 창고 (IOI11_ricehub)C++14
68 / 100
1094 ms1740 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...