Submission #1245722

#TimeUsernameProblemLanguageResultExecution timeMemory
1245722lopkusHacker (BOI15_hac)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int int64_t signed main() { int n; std::cin >> n; std::vector<int> a(n + 1); for(int i = 1; i <= n; i++) { std::cin >> a[i]; } std::vector<int> pref(n + 2); for(int i = 1; i <= n; i++) { pref[i] = pref[i - 1] + a[i]; } std::function<int(int, int)> sum = [&] (int l, int r) { if(l > r) { return 0LL; } else { return pref[r] - pref[l - 1]; } }; int ans = 0; for(int i = 1; i <= n; i++) { int mn = 1e18; int k = (n + 1) / 2; for(int j = i; j >= std::max(1LL, i - k + 1); j--) { mn = std::min(mn, sum(j, i) + sum(i + 1, k + j - 1)); } for(int j = i; j <= std::min(n, i + k - 1); j++) { mn = std::min(mn, sum(i, j) + sum(j + 1 - k, i - 1)); } if(k >= i) { for(int j = i; j <= std::min(n, i + k - 2); j++) { mn = std::min(mn, sum(1, i) + sum(i, j) + sum(j + n - k + 1, n)); } } if(k >= n - i + 1) { for(int j = i; j >= std::max(1LL, i - k + 2); j--) { mn = std::min(mn, sum(j, i) + sum(i + 1, n) + sum(1, k - n + j - 1)); } } ans = std::max(ans, mn); } std::cout << ans; }

Compilation message (stderr)

hac.cpp: In lambda function:
hac.cpp:21:22: error: inconsistent types 'long long int' and 'long int' deduced for lambda return type
   21 |       return pref[r] - pref[l - 1];
hac.cpp: In function 'int main()':
hac.cpp:28:33: error: no matching function for call to 'max(long long int, int64_t)'
   28 |     for(int j = i; j >= std::max(1LL, i - k + 1); j--) {
      |                         ~~~~~~~~^~~~~~~~~~~~~~~~
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 hac.cpp:1:
/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:
hac.cpp:28:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   28 |     for(int j = i; j >= std::max(1LL, i - k + 1); j--) {
      |                         ~~~~~~~~^~~~~~~~~~~~~~~~
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 hac.cpp:1:
/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:
hac.cpp:28:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   28 |     for(int j = i; j >= std::max(1LL, i - k + 1); j--) {
      |                         ~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from hac.cpp:1:
/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:
hac.cpp:28:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |     for(int j = i; j >= std::max(1LL, i - k + 1); j--) {
      |                         ~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from hac.cpp:1:
/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:
hac.cpp:28:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |     for(int j = i; j >= std::max(1LL, i - k + 1); j--) {
      |                         ~~~~~~~~^~~~~~~~~~~~~~~~
hac.cpp:40:35: error: no matching function for call to 'max(long long int, int64_t)'
   40 |       for(int j = i; j >= std::max(1LL, i - k + 2); j--) {
      |                           ~~~~~~~~^~~~~~~~~~~~~~~~
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 hac.cpp:1:
/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:
hac.cpp:40:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   40 |       for(int j = i; j >= std::max(1LL, i - k + 2); j--) {
      |                           ~~~~~~~~^~~~~~~~~~~~~~~~
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 hac.cpp:1:
/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:
hac.cpp:40:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   40 |       for(int j = i; j >= std::max(1LL, i - k + 2); j--) {
      |                           ~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from hac.cpp:1:
/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:
hac.cpp:40:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   40 |       for(int j = i; j >= std::max(1LL, i - k + 2); j--) {
      |                           ~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from hac.cpp:1:
/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:
hac.cpp:40:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   40 |       for(int j = i; j >= std::max(1LL, i - k + 2); j--) {
      |                           ~~~~~~~~^~~~~~~~~~~~~~~~