제출 #1275114

#제출 시각아이디문제언어결과실행 시간메모리
1275114almaz은행 (IZhO14_bank)C++17
71 / 100
1098 ms62540 KiB
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

#pragma warning(disable:4996)
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n , m;
	scanf( "%d%d" ,&n , &m);
	
	vector <int> a(n) , b(m);
	
	for(int i = 0;i < n;i++){
		scanf("%d" ,&a[i]);
	}
	for(int i = 0;i < m;i++){
		scanf("%d" ,&b[i]);
	}
	
	unordered_map <int, set <int>> mp;
	
	for(int i = 0;i < (1 << m);i++){
		int sum = 0;
		for(int j = 0;j < m;j++){
			if(1 & (i >> j)){
				sum += b[j];
			}
		}
		mp[sum].insert(i);
	}
	set <int> g;
	g.insert(0);
	
	
	for(int i = 0;i < n;i++){
		set <int> cnt;
		for(int j : mp[a[i]]){
			for(int k : g){
				if((k & j) == 0){
					cnt.insert(k | j);
				} 
			}
		}
		swap(cnt , g);
	}
	
	int f = 0;
	if(g.size() > 0){
		f = 1;
	}
	
	if(f){
		printf("YES");
	}
	else{
		printf("NO");
	}
}

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

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