Submission #972503

#TimeUsernameProblemLanguageResultExecution timeMemory
972503rahidilbayramliRice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("-O3") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #include "ricehub.h" #define ll long long #define ld long double #define vl vector<ll> #define vi vector<int> #define pii pair<int, int> #define pll pair<ll, ll> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define pb push_back #define p_b pop_back #define f first #define s second using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; int besthub(int r, int l, int x[], int b) { int v[r+5], pref[r+5]; for(int i = 1; i <= r; i++) { v[i] = x[i-1]; pref[i] = pref[i-1] + v[i]; } int ans = 0; for(ll i = 1; i <= r; i++) { ll L = i, R = r; while(L <= R) { int mid = (L + R) / 2; int idx = (L + mid) / 2; ll sum1 = pref[i] - pref[max(0LL, idx - 2)]; ll sum2 = pref[idx] - pref[mid - 1]; ll cost = v[idx] * (idx - i) - sum1 + sum2 - v[idx] * (mid - idx); if(cost <= b) { ans = max(ans, mid - i + 1); L = mid + 1; } else R = mid - 1; } } return ans; } /* void solve() { int r, l, b; cin >> r >> l >> b; int x[r]; for(int i = 0; i < r; i++) cin >> x[i]; cout << besthub(r, l, x, b) << "\n"; } int main() { ll tests = 1; //cin >> tests; while(tests--) { solve(); } }*/

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, int)':
ricehub.cpp:37:54: error: no matching function for call to 'max(long long int, int)'
   37 |             ll sum1 = pref[i] - pref[max(0LL, idx - 2)];
      |                                                      ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from ricehub.cpp:2:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
ricehub.cpp:37:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   37 |             ll sum1 = pref[i] - pref[max(0LL, idx - 2)];
      |                                                      ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from ricehub.cpp:2:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
ricehub.cpp:37:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   37 |             ll sum1 = pref[i] - pref[max(0LL, idx - 2)];
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
ricehub.cpp:37:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |             ll sum1 = pref[i] - pref[max(0LL, idx - 2)];
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
ricehub.cpp:37:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |             ll sum1 = pref[i] - pref[max(0LL, idx - 2)];
      |                                                      ^
ricehub.cpp:42:43: error: no matching function for call to 'max(int&, long long int)'
   42 |                 ans = max(ans, mid - i + 1);
      |                                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from ricehub.cpp:2:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
ricehub.cpp:42:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   42 |                 ans = max(ans, mid - i + 1);
      |                                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from ricehub.cpp:2:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
ricehub.cpp:42:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   42 |                 ans = max(ans, mid - i + 1);
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
ricehub.cpp:42:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |                 ans = max(ans, mid - i + 1);
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
ricehub.cpp:42:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |                 ans = max(ans, mid - i + 1);
      |                                           ^