Submission #170411

# Submission time Handle Problem Language Result Execution time Memory
170411 2019-12-25T06:05:12 Z div2der Bank (IZhO14_bank) C++14
0 / 100
7 ms 5112 KB
#include <iostream>
#include <vector>
using namespace std;

#define sz(s) (int)(s.size())
#define eb emplace_back

const int N = 2e5 + 5;

vector <int> v[N];

bool u[20][1 << 20];

int a[N], b[N];

void rec(int pos, int state, int n) {
	if (pos == n) {
		cout << "YES";
		exit(0);
	}
	
	if (u[pos][state])
		return;
	u[pos][state] = true;
	
	for (auto to : v[pos]) {
		if (state & to)
			continue;
		rec(pos + 1, state | to, n);
	}
}

int main () {
	cerr << "Ready\n";
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++ i)
		cin >> a[i];
	
	for (int i = 0; i < m; ++ i)
		cin >> b[i];
		
	for (int state = 0; state < (1 << m); ++ state) {
		int sum = 0;
		for (int i = 0; i < m; ++ i)
			if (state & (1 << i))
				sum += b[i];
		for (int i = 0; i < n; ++ i)
			if (sum == a[i])
				v[i].eb(state);
	}
	rec(0, 0, n);
	cout << "NO";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -