Submission #410782

#TimeUsernameProblemLanguageResultExecution timeMemory
410782LouayFarahRice Hub (IOI11_ricehub)C++14
0 / 100
15 ms1740 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int R, int L, int X[], long long B) { if(R==1) return 1; int mediane = X[R/2]; int l = R/2-1, r = R/2+1; int res = 1; while((r<R||l>=0)&&(B>=0)) { if(l<0) { res++; B-=abs(mediane-X[r]); r++; } else if(r==R) { res++; B-=abs(mediane-X[l]); l--; } else if(abs(X[l]-mediane)<=abs(X[r]-mediane)) { res++; B-=abs(mediane-X[l]); l--; } else if(abs(X[l]-mediane)>abs(X[r]-mediane)) { res++; B-=abs(mediane-X[r]); r++; } } return res-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...