# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551871 | 2022-04-21T18:47:22 Z | ala2 | Rice Hub (IOI11_ricehub) | C++14 | 3 ms | 724 KB |
#include "ricehub.h" #include <iostream> using namespace std; int n,d; int a[1000100]; int b; int P[1001000]; int suf[1000100]; int f(int i,int j) { int x=(i+j)/2; x=a[x]; int g=0; for(int o=i; o<=j; o++) g+=abs(a[o]-x); return g; } int ok(int mid) { int x=f(0,mid); int cur=a[mid/2]; int old=a[mid/2]; int mn=x; int l=a[0]; int r=a[mid]; for(int i=1;i<n-mid;i++) { cur=a[(i+i+mid)/2]; int g=x; g-=old-l; g+=P[ (i+i+mid)/2 ]-P[ (i-1+i-1+mid)/2 ]-1; g+=a[i+mid]-cur; g-= suf[ (i+i+mid)/2 ] - suf[ i+mid ]-1 ; mn=min(mn,g); old=cur; l=a[i]; r=a[i+mid]; x=g; } return mn<=b; } int besthub(int R, int L, int X[], long long B) { n=R; d=L; b=B; for(int i=0; i<n; i++) a[i]=X[i]; int mx=1; P[0]=1; for(int i=0;i<n;i++) { if(i) P[i]=1+P[i-1]; } suf[n-1]=1; for(int i=n-2;i>=0;i--) { suf[i]=1+suf[i+1]; } int l=0; int r=n; while(r-l>1) { int mid=(l+r)/2; if(ok(mid)) { l=mid; } else r=mid; } int ann=l+1; //cout<<mx<<endl; return ann; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Incorrect | 1 ms | 340 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 724 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |