Submission #895831

# Submission time Handle Problem Language Result Execution time Memory
895831 2023-12-30T22:05:43 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

typedef long long ll;

ll r, l, x, b;
vector<ll> pref;

ll check(int R, int L, int *fields, ll B) {
  ll lo = L, hi = R;
  while (lo < hi){
    ll mid = (lo + hi + 1)/2;
    ll k = (L + mid)/2;
    ll cost = fields[k - 1]*(k - L + 1) - (pref[k] - pref[L - 1]) +(pref[mid] - pref[k]) - (mid - k)*fields[k-1];

    if (cost > B) {
      hi = mid - 1;
    } else {
      lo = mid;
    }
  }

  return lo - L + 1;
}

ll besthub(int R, int L, int fields[], ll B) {
  pref.resize(R + 1);
  for(int i = 0; i < R; i++){
    pref[i+1] += pref[i];
    pref[i+1] += fields[i];
  }
  
  ll ans = INT_MIN;
  for (int i = 1; i <= R; i++) {
    ans = max(ans, check(R, i, fields, B));
  }
  return ans;
}

Compilation message

ricehub.cpp:27:4: error: ambiguating new declaration of 'll besthub(int, int, int*, ll)'
   27 | ll besthub(int R, int L, int fields[], ll B) {
      |    ^~~~~~~
In file included from ricehub.cpp:2:
ricehub.h:1:5: note: old declaration 'int besthub(int, int, int*, long long int)'
    1 | int besthub(int R, int L, int X[], long long B);
      |     ^~~~~~~