# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
655652 | 2022-11-05T05:39:26 Z | Trumling | Rice Hub (IOI11_ricehub) | C++14 | 2 ms | 308 KB |
#include "ricehub.h" #include<iostream> #include<cmath> using namespace std; typedef long long ll; #define pb push_back #define F first #define S second #define enter cout<<'\n'; int besthub(int R, int L, int X[], long long B) { ll ans=1; ll plus,l,r; l=1; r=R; bool ok=false; while(l<r) { if(plus==l || plus==r) break; ok=false; plus=(l+r)/2; bool pre=false; ll curr=0; for(int i=0;i<=R-plus;i++) { ll med; if(!pre) { med=(i+i+plus-1)/2; for(int j=i;j<i+plus;j++) curr+=abs(X[med]-X[j]); pre=true; } else { med++; ll dif=abs(X[med]-X[med-1]); curr+=abs(i-med)*dif; curr-=(plus-abs(i-med-1))*dif; curr+=abs(X[med]-X[i+plus-1]); curr-=abs(X[med-1]-X[i-1]); } if(curr<=B) { ans=max(plus,ans); ok=true; break; } } if(ok) l=plus; else r=plus; } //cout<<'\n'<<ans<<'\n'; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |