제출 #224679

#제출 시각아이디문제언어결과실행 시간메모리
224679monus1042쌀 창고 (IOI11_ricehub)C++17
68 / 100
1093 ms1152 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; #define ll long long int besthub(int R, int L, int X[], long long B) { int ans=0; long long cost=0; for (int i=0; i<R; i++){ cost=0; int pans=0, pos; for (int j=0; j<R; j++){ if (X[j] == X[i]){ pos=j; break; } } int pl=pos-1, pr=pos; while(1){ if (pl<0 && pr>=R) break; else if (pr>=R){ ll tl = X[i] - X[pl]; if (cost + tl <= B){ cost+=tl; pans++; pl--; }else break; }else if (pl<0){ ll tr = X[pr] - X[i]; if (cost + tr <= B){ cost+=tr; pans++; pr++; }else break; }else{ ll tr=X[pr] - X[i], tl=X[i] - X[pl]; if (tr<tl){ if (cost + tr <= B){ cost+=tr; pans++; pr++; }else break; }else{ if (cost + tl <= B){ cost+=tl; pans++; pl--; }else break; } } } ans=max(ans, pans); } 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...