제출 #337552

#제출 시각아이디문제언어결과실행 시간메모리
337552KerimBank (IZhO14_bank)C++17
71 / 100
1100 ms86656 KiB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int dp[20][1<<20],cost[1<<20];
int a[20],b[20];
int rec(int pos,int mask){
	if(pos<0)
		return 1;
	int &ret=dp[pos][mask];
	for(int sub=mask;sub;--sub,sub&=mask)
		if(cost[sub]==a[pos] and rec(pos-1,mask^sub))
			return ret=1;
	return ret=0;	
}
int main(){
    //freopen("file.in", "r", stdin);
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	for(int i=0;i<m;i++)
		scanf("%d",b+i);
	for(int i=0;i<(1<<m);i++)
		for(int j=0;j<m;j++)
			if(i>>j&1)
				cost[i]+=b[j];
	memset(dp,-1,sizeof dp);
	if(rec(n-1,(1<<m)-1))
		puts("YES");
	else
		puts("NO");
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
bank.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |   scanf("%d",a+i);
      |   ~~~~~^~~~~~~~~~
bank.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |   scanf("%d",b+i);
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...