Submission #1099251

#TimeUsernameProblemLanguageResultExecution timeMemory
1099251PhuocSjeckanje (COCI21_sjeckanje)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define el '\n'; #define ll long long #define fi first #define se second #define BIT(mask, i) (((mask) >> (i)) & 1) #define MASK(i) (1LL << (i)) template <class T1, class T2> bool minimize(T1 &a, T2 b) { if(a > b) {a = b; return true;} return false; } template <class T1, class T2> bool maximize(T1 &a, T2 b) { if(a < b) {a = b; return true;} return false; } const int MOD = (int)1e9 + 7; template <class T1, class T2> void add (T1 &a, T2 b) { a += b; if (a >= MOD) a -= MOD; } const int N = 200100; const int oo = (int)1e9 + 7; const ll INF = (ll)1e18 + 9LL; const int LOG = 22; int n, q, a[N]; void init (void) { cin >> n >> q; for (int i = 1; i <= n; i++) cin >> a[i]; } namespace subtask1 { long long mi[222][222], ma[222][222]; long long dp[222]; void solve (void) { while(q--) { int l, r, x; cin >> l >> r >> x; for (int i = l; i <= r; i++) a[i] += x; for (int i = 1; i <= n; i++) { mi[i][i] = a[i]; ma[i][i] = a[i]; for (int j = i + 1; j <= n; j++) { mi[i][j] = min(mi[i][j - 1], a[j]); ma[i][j] = max(ma[i][j - 1], a[j]); } } for (int i = 1; i <= n; i++) { dp[i] = ma[1][i] - mi[1][i]; // cout << dp[i] << el; for (int j = 0; j < i; j++) { maximize(dp[i], dp[j] + 1LL * ma[j + 1][i] - 1LL * mi[j + 1][i]); } } cout << dp[n] << el; } } } namespace subtask2 { long long dp[3333]; int diff[3333], pre[3333]; void solve (void) { while(q--) { bool isMonotonous = true; int l, r, x; cin >> l >> r >> x; for (int i = l; i <= r; i++) a[i] += x; bool mark = (a[2] - a[1] > 0); for (int i = 3; i <= n; i++) { if(a[i] == a[i - 1]) continue; bool t = (a[i] - a[i - 1] > 0); if(mark != t) { isMonotonous = false; break; } } if(!isMonotonous) { int cur_min = a[1], cur_max = a[1]; vector <int> pre (n + 1, 0), suf (n + 1, 0); for (int i = 1; i <= n; i++) { maximize(cur_max, a[i]); minimize(cur_min, a[i]); pre[i] = cur_max - cur_min; } cur_min = a[n], cur_max = a[n]; for (int i = n; i >= 1; i--) { maximize(cur_max, a[i]); minimize(cur_min, a[i]); suf[i] = cur_max - cur_min; } long long ans = 0; for (int i = 1; i < n; i++) { maximize(ans, pre[i] + suf[i + 1]); } cout << ans << el; } else { for (int i = 1; i < n; i++) diff[i] = a[i] - a[i + 1]; for (int i = 1; i < n; i++) pre[i] = pre[i - 1] + diff[i]; for (int i = 1; i < n; i++) { dp[i] = dp[i - 1]; maximize(dp[i], dp[i - 2] + diff[i]); } cout << dp[n]; } } } } void solve (void) { subtask1::solve(); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ntest = 1; while(ntest--) { init(); solve(); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void subtask1::solve()':
Main.cpp:54:54: error: no matching function for call to 'min(long long int&, int&)'
   54 |                     mi[i][j] = min(mi[i][j - 1], a[j]);
      |                                                      ^
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 Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:54:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   54 |                     mi[i][j] = min(mi[i][j - 1], a[j]);
      |                                                      ^
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 Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:54:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   54 |                     mi[i][j] = min(mi[i][j - 1], a[j]);
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:54:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   54 |                     mi[i][j] = min(mi[i][j - 1], a[j]);
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:54:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   54 |                     mi[i][j] = min(mi[i][j - 1], a[j]);
      |                                                      ^
Main.cpp:55:54: error: no matching function for call to 'max(long long int&, int&)'
   55 |                     ma[i][j] = max(ma[i][j - 1], a[j]);
      |                                                      ^
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 Main.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:
Main.cpp:55:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   55 |                     ma[i][j] = max(ma[i][j - 1], a[j]);
      |                                                      ^
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 Main.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:
Main.cpp:55:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   55 |                     ma[i][j] = max(ma[i][j - 1], a[j]);
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.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:
Main.cpp:55:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   55 |                     ma[i][j] = max(ma[i][j - 1], a[j]);
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.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:
Main.cpp:55:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   55 |                     ma[i][j] = max(ma[i][j - 1], a[j]);
      |                                                      ^