Submission #854216

# Submission time Handle Problem Language Result Execution time Memory
854216 2023-09-26T11:41:02 Z stdfloat Bank (IZhO14_bank) C++17
71 / 100
1000 ms 7248 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int n, m;
	cin >> n >> m;

	vector<int> a(n + 1), p(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		p[i] = p[i - 1] + a[i];
	}

	vector<int> b(m);
	for (int i = 0; i < m; i++) cin >> b[i];

	vector<int> sum(1<<m);
	for (int j = 0; j < 1<<m; j++) {
		for (int i = 0; i < m; i++) {
			if ((j>>i) & 1) sum[j] += b[i];
		}
	}

	vector<vector<bool>> dp(n + 1, vector<bool>(1<<m));

	for (int j = 0; j < 1<<m; j++) {
		dp[0][j] = true;
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 1<<m; j++) {
			if (sum[j] == p[i] && dp[i - 1][j]) dp[i][j] = true;
		}
		for (int j = 0; j < 1<<m; j++) {
			for (int k = 0; k < m; k++) {
				if (((j>>k) & 1) && dp[i][j - (1<<k)]) dp[i][j] = true;
			}
		}
	}

	cout << (count(dp[n].begin(), dp[n].end(), true) ? "YES" : "NO");
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 4 ms 604 KB Output is correct
5 Correct 141 ms 4824 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 143 ms 4808 KB Output is correct
9 Correct 141 ms 4944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 10 ms 344 KB Output is correct
4 Correct 15 ms 548 KB Output is correct
5 Correct 10 ms 344 KB Output is correct
6 Correct 6 ms 348 KB Output is correct
7 Correct 5 ms 600 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 9 ms 344 KB Output is correct
10 Correct 10 ms 344 KB Output is correct
11 Correct 14 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 4 ms 604 KB Output is correct
5 Correct 141 ms 4824 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 143 ms 4808 KB Output is correct
9 Correct 141 ms 4944 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 10 ms 344 KB Output is correct
21 Correct 4 ms 348 KB Output is correct
22 Correct 10 ms 344 KB Output is correct
23 Correct 15 ms 548 KB Output is correct
24 Correct 10 ms 344 KB Output is correct
25 Correct 6 ms 348 KB Output is correct
26 Correct 5 ms 600 KB Output is correct
27 Correct 4 ms 344 KB Output is correct
28 Correct 9 ms 344 KB Output is correct
29 Correct 10 ms 344 KB Output is correct
30 Correct 14 ms 344 KB Output is correct
31 Correct 219 ms 4944 KB Output is correct
32 Correct 293 ms 5204 KB Output is correct
33 Correct 587 ms 5836 KB Output is correct
34 Correct 804 ms 6008 KB Output is correct
35 Correct 874 ms 6224 KB Output is correct
36 Execution timed out 1039 ms 7248 KB Time limit exceeded
37 Halted 0 ms 0 KB -