Submission #97394

#TimeUsernameProblemLanguageResultExecution timeMemory
97394Shafin666Rice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<ll, ll> #define to second #define cost first typedef long long ll; typedef long double ld; using namespace std; ll a[1000005]; ll l[1000005]; bool can(int i, int j, ll b) { int mid = (i+j)/2; ll l = (mid-i+1)*a[mid] - (l[mid]-l[i-1]); ll r = l[j]-l[mid-1] - (j-mid+1)*a[mid]; return l+r <= b; } ll besthub(int r, int l, int x[], ll b) { ll answer = 0; ll inf = 1e9+7, maxlen = -1; for(int i = 0; i < r; i++) a[i+1] = r[i]; for(int i = 1; i <= r; i++) l[i] = l[i-1] + a[i]; int ptr = 1; for(int i = 1; i <= r; i++) { ptr = max(i, ptr); while(ptr+1 <= r && can(i, ptr+1, b)) ptr++; maxlen = max(maxlen, ptr-i+1); } return maxlen; } /* int main() { int x[1] = {1}; cout << besthub(1, 20, x, 6) << endl; return 0; }*/

Compilation message (stderr)

ricehub.cpp: In function 'bool can(int, int, ll)':
ricehub.cpp:17:34: error: invalid types 'll {aka long long int}[int]' for array subscript
  ll l = (mid-i+1)*a[mid] - (l[mid]-l[i-1]);
                                  ^
ricehub.cpp:17:41: error: invalid types 'll {aka long long int}[int]' for array subscript
  ll l = (mid-i+1)*a[mid] - (l[mid]-l[i-1]);
                                         ^
ricehub.cpp:18:12: error: invalid types 'll {aka long long int}[int]' for array subscript
  ll r = l[j]-l[mid-1] - (j-mid+1)*a[mid];
            ^
ricehub.cpp:18:21: error: invalid types 'll {aka long long int}[int]' for array subscript
  ll r = l[j]-l[mid-1] - (j-mid+1)*a[mid];
                     ^
ricehub.cpp: In function 'll besthub(int, int, int*, ll)':
ricehub.cpp:26:41: error: invalid types 'int[int]' for array subscript
  for(int i = 0; i < r; i++) a[i+1] = r[i];
                                         ^
ricehub.cpp:27:33: error: invalid types 'int[int]' for array subscript
  for(int i = 1; i <= r; i++) l[i] = l[i-1] + a[i];
                                 ^
ricehub.cpp:27:42: error: invalid types 'int[int]' for array subscript
  for(int i = 1; i <= r; i++) l[i] = l[i-1] + a[i];
                                          ^
ricehub.cpp:33:31: error: no matching function for call to 'max(ll&, int)'
   maxlen = max(maxlen, ptr-i+1);
                               ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
ricehub.cpp:33:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   maxlen = max(maxlen, ptr-i+1);
                               ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
ricehub.cpp:33:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   maxlen = max(maxlen, ptr-i+1);
                               ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
ricehub.cpp:33:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   maxlen = max(maxlen, ptr-i+1);
                               ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from ricehub.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
ricehub.cpp:33:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   maxlen = max(maxlen, ptr-i+1);
                               ^
ricehub.cpp:23:5: warning: unused variable 'answer' [-Wunused-variable]
  ll answer = 0;
     ^~~~~~
ricehub.cpp:24:5: warning: unused variable 'inf' [-Wunused-variable]
  ll inf = 1e9+7, maxlen = -1;
     ^~~