Submission #1127361

#TimeUsernameProblemLanguageResultExecution timeMemory
1127361julia_08Rice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int MAXN = 5e3 + 10;

ll s[MAXN];

int besthub(int r, int l, int x[], ll b){

  vector<ll> val(r + 1), d(r + 1);

  for(int i=1; i<=r; i++){
    d[i] = (ll) x[i - 1];
  }

  for(int i=1; i<=r; i++){
    s[i] = s[i - 1] + d[i];
    // cout << i << " " << s[i] << "\n";
  }

  int ans = 0;

  for(ll i=1; i<=r; i++){

    val[0] = -1e18;

    for(ll j=1; j<=r; j++){
      val[j] = -(s[j - 1] - j * d[i]);
    }

    for(ll j=i; j<=r; j++){

      ll cost = d[j] * (j - i + 1) - (s[j] - s[i - 1]) + (i + 1) * d[i] - s[i];

      int pos = lower_bound(val.begin(), val.end(), cost - b) - val.begin();

      // cout << i << " " << j << " " << pos << "\n";

      if(pos <= 0) continue;

      ans = max(ans, j - pos + 1);

    }
  }

  return ans;
}

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:45:16: error: no matching function for call to 'max(int&, ll)'
   45 |       ans = max(ans, j - pos + 1);
      |             ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from ricehub.cpp:2:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   45 |       ans = max(ans, j - pos + 1);
      |             ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from ricehub.cpp:2:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   45 |       ans = max(ans, j - pos + 1);
      |             ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |       ans = max(ans, j - pos + 1);
      |             ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
ricehub.cpp:45:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |       ans = max(ans, j - pos + 1);
      |             ~~~^~~~~~~~~~~~~~~~~~