Submission #68447

# Submission time Handle Problem Language Result Execution time Memory
68447 2018-08-17T07:14:51 Z cdemirer Bank (IZhO14_bank) C++17
44 / 100
241 ms 50204 KB
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef pair<double, double> dodo;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)


int N, M;
int A[20], B[20];
unordered_map<int, int> table;

int main(int argc, char **argv) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A+N);// reverse(A, A+N);
	for (int i = 0; i < M; i++) cin >> B[i];
	sort(B, B+M);// reverse(B, B+M);
	int mlim = 1<<M;
	int used = 0;
	for (int i = 0; i < N; i++) {
		bool flag = false;
		for (int m = mlim-1; m > 0; m--) {
			if (m & used) continue;
			if (!table[m]) {
				int sum = 0;
				for (int k = 0; k < M; k++) if (m & (1<<k)) sum += B[k];
				table[m] = sum;
				//cerr << "m: " << m << "   val: " << table[m] << endl;
			}
			if (table[m] == A[i]) {
				used |= m;
				flag = true;
				break;
			}
		}
		if (!flag) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 4 ms 740 KB Output is correct
5 Correct 241 ms 50204 KB Output is correct
6 Correct 2 ms 50204 KB Output is correct
7 Correct 2 ms 50204 KB Output is correct
8 Correct 8 ms 50204 KB Output is correct
9 Correct 235 ms 50204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 50204 KB Output is correct
2 Correct 2 ms 50204 KB Output is correct
3 Correct 2 ms 50204 KB Output is correct
4 Correct 2 ms 50204 KB Output is correct
5 Correct 2 ms 50204 KB Output is correct
6 Correct 2 ms 50204 KB Output is correct
7 Correct 2 ms 50204 KB Output is correct
8 Correct 2 ms 50204 KB Output is correct
9 Correct 2 ms 50204 KB Output is correct
10 Correct 2 ms 50204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 50204 KB Output is correct
2 Correct 4 ms 50204 KB Output is correct
3 Correct 5 ms 50204 KB Output is correct
4 Correct 5 ms 50204 KB Output is correct
5 Correct 5 ms 50204 KB Output is correct
6 Correct 5 ms 50204 KB Output is correct
7 Incorrect 3 ms 50204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 4 ms 740 KB Output is correct
5 Correct 241 ms 50204 KB Output is correct
6 Correct 2 ms 50204 KB Output is correct
7 Correct 2 ms 50204 KB Output is correct
8 Correct 8 ms 50204 KB Output is correct
9 Correct 235 ms 50204 KB Output is correct
10 Correct 2 ms 50204 KB Output is correct
11 Correct 2 ms 50204 KB Output is correct
12 Correct 2 ms 50204 KB Output is correct
13 Correct 2 ms 50204 KB Output is correct
14 Correct 2 ms 50204 KB Output is correct
15 Correct 2 ms 50204 KB Output is correct
16 Correct 2 ms 50204 KB Output is correct
17 Correct 2 ms 50204 KB Output is correct
18 Correct 2 ms 50204 KB Output is correct
19 Correct 2 ms 50204 KB Output is correct
20 Correct 4 ms 50204 KB Output is correct
21 Correct 4 ms 50204 KB Output is correct
22 Correct 5 ms 50204 KB Output is correct
23 Correct 5 ms 50204 KB Output is correct
24 Correct 5 ms 50204 KB Output is correct
25 Correct 5 ms 50204 KB Output is correct
26 Incorrect 3 ms 50204 KB Output isn't correct
27 Halted 0 ms 0 KB -