Submission #823364

# Submission time Handle Problem Language Result Execution time Memory
823364 2023-08-12T11:38:08 Z 12345678 Rice Hub (IOI11_ricehub) C++17
100 / 100
15 ms 3320 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int besthub(int R, int L, int X[], long long B)
{
  int ans=1;
  vector<ll> qs(R+1), v(R+1);
  for (int i=0; i<R; i++) v[i+1]=X[i], qs[i+1]=qs[i]+v[i+1];
  for (int i=1; i<=R; i++) 
  {
    int l=i, r=R;
    while (l<r)
    {
        int m=(l+r+1)/2;
        int md=(i+m)/2;
        ll ls=v[md]*(md-i+1)-(qs[md]-qs[i-1]);
        ll rs=qs[m]-qs[md]-v[md]*(m-md);
        if (ls+rs<=B) l=m;
        else r=m-1;
    }
    ans=max(ans, l-i+1);
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 264 KB Output is correct
10 Correct 0 ms 252 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 288 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 12 ms 2220 KB Output is correct
4 Correct 13 ms 3320 KB Output is correct
5 Correct 6 ms 1620 KB Output is correct
6 Correct 7 ms 1572 KB Output is correct
7 Correct 12 ms 2988 KB Output is correct
8 Correct 12 ms 3028 KB Output is correct
9 Correct 7 ms 1568 KB Output is correct
10 Correct 9 ms 1600 KB Output is correct
11 Correct 13 ms 3276 KB Output is correct
12 Correct 13 ms 3244 KB Output is correct
13 Correct 6 ms 1584 KB Output is correct
14 Correct 6 ms 1620 KB Output is correct
15 Correct 13 ms 2496 KB Output is correct
16 Correct 10 ms 2504 KB Output is correct
17 Correct 11 ms 2960 KB Output is correct
18 Correct 15 ms 2900 KB Output is correct
19 Correct 13 ms 3092 KB Output is correct
20 Correct 12 ms 3156 KB Output is correct