답안 #173484

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173484 2020-01-04T09:03:29 Z tourist 은행 (IZhO14_bank) C++14
19 / 100
76 ms 4524 KB
#include <iostream>
#include <vector>

using namespace std;

#define ll long long
#define sz(x) (int)x.size()
#define pii pair < int, int >
#define endl "\n"
#define METH ios::sync_with_stdio(0); cin.tie(0);
#define BEGIN cout << "BEGIN" << endl;
#define END cout << "END" << endl;

const int mod = 1e9 + 7;															/// ANOTHER HASH MOD: 228228227
const int prime = 29;																	/// ANOTHER HASH PRIME: 997
const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8);

int n, m;
vector < int > done;
vector < int > a, b, dp;

inline void read() {
	scanf("%d %d", &n, &m);
	a.resize(n);
	b.resize(m);
	done.resize(2000);
	dp.resize(1 << m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		done[a[i]]++;
	}
	for (int i = 0; i < m; i++) {
		scanf("%d", &b[i]);
	}
}

inline int solve() {
	for (int i = 0; i < (1 << m); i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			if (i >> j & 1) {
				sum += b[j];
			}
		}
		if (done[sum]) {
			return cout << "YES" << endl, 0;
		}
	}

	cout << "NO" << endl;
}

int main() {
	int t = 1;
	while (t--) {
		read();
		solve();
	}
}

Compilation message

bank.cpp: In function 'void read()':
bank.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
bank.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
bank.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &b[i]);
   ~~~~~^~~~~~~~~~~~~
bank.cpp: In function 'int solve()':
bank.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 76 ms 4472 KB Output is correct
6 Correct 2 ms 392 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 6 ms 4472 KB Output is correct
9 Correct 76 ms 4524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 76 ms 4472 KB Output is correct
6 Correct 2 ms 392 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 6 ms 4472 KB Output is correct
9 Correct 76 ms 4524 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Incorrect 2 ms 256 KB Output isn't correct
14 Halted 0 ms 0 KB -