Submission #235809

#TimeUsernameProblemLanguageResultExecution timeMemory
235809MasterdanRice Hub (IOI11_ricehub)C++14
0 / 100
7 ms768 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define MAX 1e9+7 #define PI 3.141592653589 #define pb push_back #define mk make_pair #define F first #define S second #define MIN -1 #define SMAX 1e18+7 #define all(a) a.begin (), a.end () using namespace std; typedef long long int ll; typedef vector <int> vi; typedef pair<int, int> ii; typedef double db; int besthub(int n, int L, int X[], ll cash) { vi v; for(int i=0;i<n;i++){ v.pb(X[i]); } //vi v1=v; //sort(all(v1)); /* ll in=1, fin=cash+1; while(in!=fin){ ll mid=(in+fin)/2; ll totalaux=0; for(int i=0;i<v1.size ();i++){ ll aux=(abs(mid-v[i])); totalaux+=aux; } if(totalaux>cash)totalaux=0; int midfin=(mid+1+fin)/2; for(int i=0;i<v1.size ();i++){ int aux=abs(midfin-v[i]); } int midin=(in+mid)/2; }*/ int in=0,fin=0; int totalaux=0,mid=0,flag=1,total=1; while(fin<n){ if(fin>=n)break; if(totalaux>cash){ totalaux=totalaux-v[mid]-v[in];in++; if(flag%2==1)mid++; flag--; } else{ fin++; totalaux=totalaux+v[fin]-v[mid];total=max(total,flag); if(flag%2==1)mid++; flag++; } } return total; } /* static int R, L; static long long B; static int X[MAX_R]; static int solution; inline void my_assert(int e) {if (!e) abort();} static void read_input() { int i; my_assert(3==scanf("%d %d %lld",&R,&L,&B)); for(i=0; i<R; i++) my_assert(1==scanf("%d",&X[i])); my_assert(1==scanf("%d",&solution)); } int main() { int ans; read_input(); ans = besthub(R,L,X,B); if(ans==solution) printf("Correct.\n"); else printf("Incorrect. Returned %d instead of %d.\n",ans,solution); return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...