Submission #742768

# Submission time Handle Problem Language Result Execution time Memory
742768 2023-05-16T21:08:18 Z Dead_Inside7 Bank (IZhO14_bank) C++17
0 / 100
2 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	vector<int> a(n),b(m);
	for(auto&v:a) cin>>v;
	for(auto&v:b) cin>>v;
	bool cc=false;
	vector<pair<long long,long long>> dp(1<<m,{-1e9,0});
	dp[0]={0,0};
    for(int i=1;i<(1<<m);i++){
	    for(int j=0;j<m;j++){
			if(i&(1<<j)){
				pair<long long,long long> mx;
				mx=dp[i^(1<<j)];
				if(mx.first==-1e9) continue;
				if(a[mx.first] == mx.second + b[j]){
					mx.second=0;
					mx.first++;
					dp[i]=max(dp[i],mx);
				}
				else if(a[mx.first] > mx.second + b[j]){
					mx.second+=b[j];
					dp[i]=max(dp[i],mx);
				}
			}
		}
		if(dp[i].first == n){
			cc=true;break;
		}
	}
	if(cc) cout<<"Yes";
	else cout<<"No";
	 return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -