답안 #1082839

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1082839 2024-09-01T17:34:44 Z elotelo966 은행 (IZhO14_bank) C++17
0 / 100
163 ms 261732 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 1005
#define fi first
#define se second

int n,m;

int a[lim],b[lim];

int dp[(1<<14)][lim];

inline int f(int mask,int sum){
	if(mask==(1<<m)-1)return 0;
	if(~dp[mask][sum])return dp[mask][sum];
	int cev=0;
	for(int i=0;i<m;i++){
		if(mask&(1<<i))continue;
		cev=max(cev,f(mask|(1<<i),sum+b[i])+((sum+b[i]==a[f(mask|(1<<i),sum+b[i])])?1:0));
	}
	return dp[mask][sum]=cev;
}

int32_t main(){
	faster
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	FOR{
		cin>>a[i-1];
	}
	
	for(int i=0;i<m;i++)cin>>b[i];
	
	int cev=f(0,0);
	
	//cout<<cev<<endl;
	
	if(cev==n)cout<<"YES"<<'\n';
	else cout<<"NO"<<'\n';
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 129128 KB Output is correct
2 Correct 58 ms 129104 KB Output is correct
3 Correct 52 ms 129104 KB Output is correct
4 Runtime error 163 ms 261732 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 129320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 129104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 129128 KB Output is correct
2 Correct 58 ms 129104 KB Output is correct
3 Correct 52 ms 129104 KB Output is correct
4 Runtime error 163 ms 261732 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -