답안 #743702

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743702 2023-05-17T18:08:09 Z Dead_Inside7 은행 (IZhO14_bank) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
	ifstream cin("bank.in");
	ofstream cout("bank.out");
	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,{-1,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==-1) continue;
				if(a[mx.first] == mx.second + b[j]){
					mx.second=0;
					mx.first++;
					dp[i]=mx;
				}
				else if((a[mx.first] > mx.second + b[j])&&(dp[i].first <= mx.first)){
					mx.second+=b[j];
					dp[i]=mx;
				}
			}
		}
		if(dp[i].first == n){
			cc=true;break;
		}
	}
	if(cc) cout<<"Yes";
	else cout<<"No";
	 return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -