Submission #1127858

#TimeUsernameProblemLanguageResultExecution timeMemory
1127858zhasynBank (IZhO14_bank)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 1e6 + 100, M = 500 + 10, len = 315, inf = 1e18;
const ll mod = 998244353;
ll um(ll a, ll b){
	return (1LL * a * b) % mod;
}
ll subr(ll a, ll b){
	return ((1LL * a - b) % mod + mod) % mod;
}
ll bp(ll x, ll step){
	ll res = 1;
	while(step){
		if(step & 1) res = um(res, x);
		x = um(x, x);
		step /= 2;
	}
	return res;
}
ll inv(ll x){
	return bp(x, mod - 2);
}
int a[N], b[N], n, m;
ll dp[N], r[N];
int main() {
	//ios_base::sync_with_stdio(false);
	//cin.tie(nullptr);
	//cout.tie(nullptr);
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	for(int mask = 0; mask < (1 << m); mask++){
		dp[mask] = -1;
	}
	dp[0] = 0;
	for(int mask = 0; mask < (1 << m); mask++){
		for(int dig = 0; dig < m; dig++){
			if((mask & (1 << dig)) > 0){
				int nw = mask ^ (1 << dig);
				if(dp[nw] == -1) continue;
				
				int mx = dp[nw], rem = r[nw];
				if(rem + b[dig] == a[mx]){
					mx++;
					rem = 0;
				} else{
					rem += b[dig];
				}
				if(mx == dp[mask]){
					r[mask] = min(r[mask], rem);
				}
			}
		}
	}
	if(dp[(1 << m) - 1] == n) cout << "YES";
	else cout << "NO";
  return 0;
}

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:62:54: error: no matching function for call to 'min(ll&, int&)'
   62 |                                         r[mask] = min(r[mask], rem);
      |                                                   ~~~^~~~~~~~~~~~~~
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 bank.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
bank.cpp:62:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   62 |                                         r[mask] = min(r[mask], rem);
      |                                                   ~~~^~~~~~~~~~~~~~
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 bank.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
bank.cpp:62:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   62 |                                         r[mask] = min(r[mask], rem);
      |                                                   ~~~^~~~~~~~~~~~~~
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 bank.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
bank.cpp:62:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   62 |                                         r[mask] = min(r[mask], rem);
      |                                                   ~~~^~~~~~~~~~~~~~
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 bank.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
bank.cpp:62:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   62 |                                         r[mask] = min(r[mask], rem);
      |                                                   ~~~^~~~~~~~~~~~~~