# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1027681 | 2024-07-19T09:01:05 Z | vjudge1 | Rice Hub (IOI11_ricehub) | C++14 | 11 ms | 3560 KB |
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; const long long MAX=1e5+10; long long pref[MAX]; vector<long long> niza; long long budget; bool can(long long x) { for(long long i=0; i<=niza.size()-x; i++) { long long idx=(i+i+x)/2; long long pt=niza[idx]; long long l=pt*(idx-i)-(pref[idx]-pref[i]+niza[i]-niza[idx]); long long r=(pref[i+x-1]-pref[idx]+niza[idx])-pt*(i+x-idx); //cout<<"for: "<<i+1<<" "<<i+x<<" lr is: "<<l<<" "<<r<<" "<<budget<<endl; if(l+r<=budget)return true; } return false; } int besthub(int R, int L, int X[], long long B) { budget=B; for(long long i=0; i<R; i++)niza.push_back(X[i]); pref[0]=X[0]; for(long long i=1; i<R; i++)pref[i]=pref[i-1]+X[i]; long long b=0; long long e=R; long long res=0; while(b<=e) { long long mid=(b+e)/2; if(can(mid)) { res=mid; b=mid+1; } else e=mid-1; } return res; } /*int main() { int R,L,B; cin>>R>>L>>B; int X[R]; budget=B; for(int i=0; i<R; i++)cin>>X[i]; for(int i=0; i<R; i++)niza.push_back(X[i]); pref[0]=X[0]; for(int i=1; i<R; i++)pref[i]=pref[i-1]+X[i]; int b=0; int e=R; int res=0; while(b<=e) { int mid=(b+e)/2; cout<<"mid: "<<mid<<endl; if(can(mid)) { res=mid; b=mid+1; } else e=mid-1; } cout<<res<<endl; return 0; } 5 20 6 1 2 10 12 14*/
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 604 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 412 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 440 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 432 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 452 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 484 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 600 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 416 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 604 KB | Output is correct |
22 | Correct | 1 ms | 604 KB | Output is correct |
23 | Correct | 1 ms | 604 KB | Output is correct |
24 | Correct | 1 ms | 604 KB | Output is correct |
25 | Correct | 1 ms | 604 KB | Output is correct |
26 | Correct | 1 ms | 604 KB | Output is correct |
27 | Correct | 1 ms | 604 KB | Output is correct |
28 | Correct | 1 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 984 KB | Output is correct |
2 | Correct | 2 ms | 1024 KB | Output is correct |
3 | Correct | 9 ms | 3532 KB | Output is correct |
4 | Correct | 10 ms | 3536 KB | Output is correct |
5 | Correct | 5 ms | 1884 KB | Output is correct |
6 | Correct | 5 ms | 1748 KB | Output is correct |
7 | Correct | 8 ms | 3280 KB | Output is correct |
8 | Correct | 8 ms | 3280 KB | Output is correct |
9 | Correct | 5 ms | 1748 KB | Output is correct |
10 | Correct | 5 ms | 1716 KB | Output is correct |
11 | Correct | 10 ms | 3372 KB | Output is correct |
12 | Correct | 11 ms | 3560 KB | Output is correct |
13 | Correct | 5 ms | 1792 KB | Output is correct |
14 | Correct | 8 ms | 1748 KB | Output is correct |
15 | Correct | 7 ms | 2768 KB | Output is correct |
16 | Correct | 7 ms | 2768 KB | Output is correct |
17 | Correct | 8 ms | 3236 KB | Output is correct |
18 | Correct | 8 ms | 3024 KB | Output is correct |
19 | Correct | 8 ms | 3280 KB | Output is correct |
20 | Correct | 9 ms | 3280 KB | Output is correct |