Submission #742071

# Submission time Handle Problem Language Result Execution time Memory
742071 2023-05-15T14:37:15 Z PagodePaiva Rice Hub (IOI11_ricehub) C++14
0 / 100
3 ms 556 KB
#include<bits/stdc++.h>
#include "ricehub.h"

using namespace std;

int besthub(int R, int L, int X[], long long B){
  int n = R, M = L;
  int v[n];

  for(int i = 0;i < n;i++){
    v[i] = X[i];
  }

  int b = B;

  int l = 1, r = n;

  int pref[n];
  pref[0] = v[0];

  for(int i = 1;i < n;i++){
    pref[i] = pref[i-1] + v[i];
  }

  while(l < r){
    int mid = (l+r)/2;
    int t = mid/2;
    bool aux = true;
    for(int i = 0;i < n-mid+1;i++){
      int p = v[i + t];
      // int val = pref[i+mid-1] - pref[i+t];
      int val = pref[i+mid-1] - (i == 0 ? 0 : pref[i-1]) - p;
      if(val <= b){
        l = mid+1;
        aux = false;
        break;
      }
    }

    if(aux){
      r = mid;
    }
  }

  return l;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:7:14: warning: unused variable 'M' [-Wunused-variable]
    7 |   int n = R, M = L;
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 556 KB Output isn't correct
2 Halted 0 ms 0 KB -