Submission #615743

# Submission time Handle Problem Language Result Execution time Memory
615743 2022-07-31T12:16:50 Z Minindu2006 Rice Hub (IOI11_ricehub) C++17
17 / 100
13 ms 3316 KB
#include "ricehub.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> pref, arr;
ll getSum(int a, int b)
{
  return pref[b] - pref[a - 1];
}
int besthub(int R, int L, int X[], long long B)
{
  pref.resize(R + 1, 0);
  arr.resize(R + 1);
  for(int i=1;i<=R;i++)
    pref[i] += pref[i - 1] + X[i - 1], arr[i] = X[i - 1];
  int ans = -1;
  // for(int i=1;i<=R;i++)
  // {
  //   for(int j=i;j<=R;j++)
  //   {
  //     int mid = (i + j) / 2;
  //     ll cur = (arr[mid] * (mid - i) - getSum(i, mid - 1)) + (getSum(mid + 1, j) - arr[mid] * (j - mid));
  //      cout << cur << '\n';
  //     if(cur <= B)
  //       ans = max(j - i + 1, ans);
  //   }
  // }
  int i = 0, j = 0;
  while(R - j > 0)
  {
    int mid = (i + j) / 2;
    ll cur = (arr[mid] * (mid - i) - getSum(i, mid - 1)) + (getSum(mid + 1, j) - arr[mid] * (j - mid));
    if(cur <= B)
      ans = max(j - i + 1, ans), j++;
    else
      i++;
  }
  return ans;
}
# 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 1 ms 212 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 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 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 308 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Incorrect 0 ms 212 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 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 340 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Incorrect 0 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 836 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 13 ms 3316 KB Output is correct
4 Correct 13 ms 3272 KB Output is correct
5 Correct 6 ms 1604 KB Output is correct
6 Correct 6 ms 1576 KB Output is correct
7 Correct 11 ms 3028 KB Output is correct
8 Correct 10 ms 3044 KB Output is correct
9 Correct 5 ms 1492 KB Output is correct
10 Correct 5 ms 1568 KB Output is correct
11 Correct 13 ms 3276 KB Output is correct
12 Correct 12 ms 3224 KB Output is correct
13 Correct 7 ms 1620 KB Output is correct
14 Correct 6 ms 1624 KB Output is correct
15 Correct 10 ms 2472 KB Output is correct
16 Incorrect 10 ms 2500 KB Output isn't correct
17 Halted 0 ms 0 KB -