Submission #1093632

#TimeUsernameProblemLanguageResultExecution timeMemory
1093632AvianshRice Hub (IOI11_ricehub)C++17
17 / 100
10 ms1856 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; bool check(int x[], int n, int siz, long long b){ int med = n/2; long long f = 0; long long s = 0; for(int i = 0;i<=med;i++){ f+=x[med]-x[i]; } for(int i = med+1;i<n;i++){ s+=x[i]-x[med]; } for(int i = 1;i<=siz-n;i++){ f+=1LL*(x[med+i]-x[med+i-1])*(med+1); f-=(x[med+i]-x[i-1]); s-=1LL*(x[med+i]-x[med+i-1])*(n-med-1); s+=(x[n+i-1]-x[med+i]); if(f+s<b){ return 1; } } return 0; } int besthub(int n, int l, int x[], long long b) { int lo = 0; int hi = n; while(lo<hi){ int mid = (lo+hi+1)/2; if(check(x,mid,n,b)){ lo=mid; } else{ hi=mid-1; } } return lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...