제출 #392613

#제출 시각아이디문제언어결과실행 시간메모리
392613vanic은행 (IZhO14_bank)C++14
71 / 100
1092 ms332 KiB
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bitset>

using namespace std;

const int maxn=20;

int n, m;
int a[maxn];
int b[maxn];

bitset < maxn > p;

bool rek(int x, int y, int br){
	if(x==n){
		return 1;
	}
	if(br==a[x]){
		return rek(x+1, 0, 0);
	}
	if(y==m || br>a[x]){
		return 0;
	}
	if(p[y]){
		return rek(x, y+1, br);
	}
	br+=b[y];
	p[y]=1;
	if(rek(x, y+1, br)){
		return 1;
	}
	br-=b[y];
	p[y]=0;
	if(rek(x, y+1, br)){
		return 1;
	}
	return 0;
}

int main(){
	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);
	}
	if(rek(0, 0, 0)){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

bank.cpp: In function 'int main()':
bank.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
bank.cpp:45:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |   scanf("%d", a+i);
      |   ~~~~~^~~~~~~~~~~
bank.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |   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...