Submission #1001414

#TimeUsernameProblemLanguageResultExecution timeMemory
1001414vjudge1Bank (IZhO14_bank)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define pll pair<long long, long long>
#define pii pair<int , int>
#define fi first
#define se second
#define x first
#define y second
#define bit(i,j) ((j >> i) & 1)
using namespace std;

const long long inf = 1e9+1;
const int mod = 1e9+7;
const int MAXN = 2e5+100;

bool dp[25][(1<<20)+1]; 
int cnt[(1 << 20) + 1];
int32_t main(){
  	//freopen("A.inp", "r", stdin);
	//freopen("A.out", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n , m; cin >> n >> m;
	vector<int> pre(n+1) , a(n+1) , b(m+1);
	for(int i = 1; i <= n ; i ++) cin >> a[i] , pre[i] = pre[i-1] + a[i];
	for(int i = 1; i <= m ; i ++) cin >> b[i];
	
	for(int msk = 1 ; msk < (1 << m) ; msk++){
		for(int i = 0 ; i < m ; i++) if(bit(i , msk)) cnt[msk] += b[i+1];
	}
	dp[0][0] = 1;
	for(int i = 1 ; i <= n ; i++){
		for(int msk = 1 ; msk < (1 << m) ; msk++){
			if(cnt[msk] != pre[i]) continue;
			for(int s = msk ; s > 0 ; s = (s-1) & msk){
				if(cnt[s] == a[i]) dp[i][msk] = max(dp[i][msk] , dp[i-1][msk ^ s]);
			}
		}
	}
	int res = 0;
	for(int msk = 1 ; msk < (1 << m) ; msk++){
		res = max(res , dp[n][msk]);
	}
	cout << (res ? "YES\n" : "NO\n");

	return 0;
}

Compilation message (stderr)

bank.cpp: In function 'int32_t main()':
bank.cpp:42:29: error: no matching function for call to 'max(int&, bool&)'
   42 |   res = max(res , dp[n][msk]);
      |                             ^
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 bank.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:
bank.cpp:42:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'bool')
   42 |   res = max(res , dp[n][msk]);
      |                             ^
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 bank.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:
bank.cpp:42:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'bool')
   42 |   res = max(res , dp[n][msk]);
      |                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bank.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:
bank.cpp:42:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |   res = max(res , dp[n][msk]);
      |                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bank.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:
bank.cpp:42:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |   res = max(res , dp[n][msk]);
      |                             ^