Submission #498343

#TimeUsernameProblemLanguageResultExecution timeMemory
498343IerusSplit the sequence (APIO14_sequence)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; */ using namespace std; #pragma GCC optimize ("unroll-loops,Ofast,O3") #pragma GCC target("avx,avx2,fma") #define F first #define S second #define sz(x) (int)x.size() #define pb push_back #define int long long #define eb emplace_back #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ; #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) //#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> typedef long long ll; const int E = 1e6+777; const long long inf = 1e18+777; const int N = 2e5+777; const int MOD = 1e9+7; const bool I = 1; int n, pref[N], k; int get(int l, int r){ return pref[r] - (l - 1 < 0 ? 0 : pref[l-1]); } signed main(){ cin >> n >> k; vector<int> a(n); for(int i = 0; i < n; ++i){ cin >> a[i]; if(!i) pref[i] = a[i]; else pref[i] = pref[i-1] + a[i]; } // cerr << "pref\n"; // for(int i = 0; i < n; ++i){ // cerr << pref[i] << ' '; // }cerr << '\n'; int res = -1; vector<int> q; for(int mask = 0; mask < (1 << max(n, 20)); ++mask){ vector<int> r; for(int a = 0; a < n; ++a){ if((mask >> a) & 1){ r.push_back(a); } } if(sz(r) != k) continue; int last = 0, ans = 0; for(int i = 0; i < sz(r); ++i){ ans += get(last, r[i]) * get(r[i] + 1, n-1); last = r[i] + 1; } if(ans > res){ res = ans; q = r; } } cout << res << '\n'; for(auto it : q){ cout << it + 1 << ' '; } } /* 7 3 4 1 3 4 0 2 3 */

Compilation message (stderr)

sequence.cpp: In function 'int main()':
sequence.cpp:45:42: error: no matching function for call to 'max(long long int&, int)'
   45 |  for(int mask = 0; mask < (1 << max(n, 20)); ++mask){
      |                                          ^
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 sequence.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:
sequence.cpp:45:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |  for(int mask = 0; mask < (1 << max(n, 20)); ++mask){
      |                                          ^
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 sequence.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:
sequence.cpp:45:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |  for(int mask = 0; mask < (1 << max(n, 20)); ++mask){
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sequence.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:
sequence.cpp:45:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |  for(int mask = 0; mask < (1 << max(n, 20)); ++mask){
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sequence.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:
sequence.cpp:45:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |  for(int mask = 0; mask < (1 << max(n, 20)); ++mask){
      |                                          ^