Submission #520617

#TimeUsernameProblemLanguageResultExecution timeMemory
520617VimmerCigle (COI21_cigle)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define in(x) freopen(x, "r", stdin) #define out(x) freopen(x, "w", stdout) #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #define F first #define S second #define PB push_back #define M ll(1e9 + 7) #define sz(x) (ll)x.size() #define N 1000500 #define pri(x) cout << x << endl #define endl '\n' #define all(x) (x).begin(), (x).end() #define _ << " " << using namespace std; //typedef tree <ll, null_type, less_equal <ll> , rb_tree_tag, tree_order_statistics_node_update> ordered_set; //using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef short int si; typedef unsigned long long ull; si f[5001][5001][2]; vector <int> was[5001]; int pr[5001]; si now[5001][5001][2]; int main() { istream::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(f, -1, sizeof f); int n; cin >> n; int a[n], ans = 0; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { pr[i] = a[i]; if (i) pr[i] += pr[i - 1]; } for (int l = 0; l < n; l++) { int sum = 0; for (int r = l; r < n; r++) { sum += a[r]; int L = r + 1, R = n - 1; while (L < R) { int md = (L + R) >> 1; if (pr[md] - pr[r] >= sum) R = md; else L = md + 1; } if (pr[L] - pr[r] == sum) { was[r].PB(L); } } } for (int i = 0; i < n; i++) sort(all(was[i])); memset(now, -1, sizeof now); for (int i = 0; i < n; i++) f[0][i][0] = 0; for (int r = 0; r < n; r++) for (int l = 0; l <= r; l++) for (int t = 0; t < 2; t++) { if (r) now[l][r][t] = max(now[l][r][t], now[l][r - 1][t]); f[l][r][t] = max(f[l][r][t], now[l][r][t]); if (f[l][r][t] != -1) { int kl = f[l][r][t]; int sm = pr[r], cur = 0; if (l) sm -= pr[l - 1]; int i = 0, bn = 0; for (int nw = r + 1; nw < n; nw++) { cur += a[nw]; if (bn) { kl++; bn = 0; } while (i < sz(was[r]) && was[r][i] == nw) { bn = 1; i++; } f[r + 1][nw][t ^ 1] = max(f[r + 1][nw][t ^ 1], kl); ans = max(ans, kl); if (sm <= cur) { now[r + 1][nw][t ^ 1] = max(now[r + 1][nw][t ^ 1], kl); break; } } } } pri(ans); }

Compilation message (stderr)

cigle.cpp: In function 'int main()':
cigle.cpp:131:82: error: no matching function for call to 'max(si&, int&)'
  131 |                                 f[r + 1][nw][t ^ 1] = max(f[r + 1][nw][t ^ 1], kl);
      |                                                                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cigle.cpp:1:
/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:
cigle.cpp:131:82: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
  131 |                                 f[r + 1][nw][t ^ 1] = max(f[r + 1][nw][t ^ 1], kl);
      |                                                                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cigle.cpp:1:
/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:
cigle.cpp:131:82: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
  131 |                                 f[r + 1][nw][t ^ 1] = max(f[r + 1][nw][t ^ 1], kl);
      |                                                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cigle.cpp:1:
/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:
cigle.cpp:131:82: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
  131 |                                 f[r + 1][nw][t ^ 1] = max(f[r + 1][nw][t ^ 1], kl);
      |                                                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cigle.cpp:1:
/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:
cigle.cpp:131:82: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
  131 |                                 f[r + 1][nw][t ^ 1] = max(f[r + 1][nw][t ^ 1], kl);
      |                                                                                  ^
cigle.cpp:137:90: error: no matching function for call to 'max(si&, int&)'
  137 |                                     now[r + 1][nw][t ^ 1] = max(now[r + 1][nw][t ^ 1], kl);
      |                                                                                          ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cigle.cpp:1:
/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:
cigle.cpp:137:90: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
  137 |                                     now[r + 1][nw][t ^ 1] = max(now[r + 1][nw][t ^ 1], kl);
      |                                                                                          ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cigle.cpp:1:
/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:
cigle.cpp:137:90: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
  137 |                                     now[r + 1][nw][t ^ 1] = max(now[r + 1][nw][t ^ 1], kl);
      |                                                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cigle.cpp:1:
/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:
cigle.cpp:137:90: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
  137 |                                     now[r + 1][nw][t ^ 1] = max(now[r + 1][nw][t ^ 1], kl);
      |                                                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cigle.cpp:1:
/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:
cigle.cpp:137:90: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
  137 |                                     now[r + 1][nw][t ^ 1] = max(now[r + 1][nw][t ^ 1], kl);
      |                                                                                          ^