답안 #854864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854864 2023-09-29T07:05:25 Z stdfloat 은행 (IZhO14_bank) C++17
100 / 100
886 ms 3280 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 (auto &i : b) cin >> 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 j = 0; j < 1<<m; j++) {
		int sm = 0;
		for (int i = 0; i < m; i++) {
			if ((j>>i) & 1) sm += b[i];
		}
		for (int i = 1; i <= n; i++) {
			if (sm == p[i] && dp[i - 1][j]) dp[i][j] = true;

			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");
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 131 ms 604 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 135 ms 604 KB Output is correct
9 Correct 134 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 7 ms 348 KB Output is correct
4 Correct 7 ms 348 KB Output is correct
5 Correct 7 ms 344 KB Output is correct
6 Correct 5 ms 464 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 7 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 131 ms 604 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 135 ms 604 KB Output is correct
9 Correct 134 ms 856 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 6 ms 348 KB Output is correct
21 Correct 4 ms 348 KB Output is correct
22 Correct 7 ms 348 KB Output is correct
23 Correct 7 ms 348 KB Output is correct
24 Correct 7 ms 344 KB Output is correct
25 Correct 5 ms 464 KB Output is correct
26 Correct 4 ms 348 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 6 ms 348 KB Output is correct
29 Correct 6 ms 348 KB Output is correct
30 Correct 7 ms 480 KB Output is correct
31 Correct 206 ms 860 KB Output is correct
32 Correct 282 ms 1116 KB Output is correct
33 Correct 399 ms 1624 KB Output is correct
34 Correct 470 ms 1892 KB Output is correct
35 Correct 491 ms 2140 KB Output is correct
36 Correct 703 ms 3212 KB Output is correct
37 Correct 212 ms 856 KB Output is correct
38 Correct 290 ms 1116 KB Output is correct
39 Correct 454 ms 1632 KB Output is correct
40 Correct 440 ms 1884 KB Output is correct
41 Correct 692 ms 3216 KB Output is correct
42 Correct 374 ms 1372 KB Output is correct
43 Correct 401 ms 1624 KB Output is correct
44 Correct 534 ms 2652 KB Output is correct
45 Correct 282 ms 1112 KB Output is correct
46 Correct 380 ms 1368 KB Output is correct
47 Correct 571 ms 2656 KB Output is correct
48 Correct 134 ms 604 KB Output is correct
49 Correct 132 ms 856 KB Output is correct
50 Correct 878 ms 3160 KB Output is correct
51 Correct 516 ms 1896 KB Output is correct
52 Correct 557 ms 1892 KB Output is correct
53 Correct 549 ms 1884 KB Output is correct
54 Correct 864 ms 3216 KB Output is correct
55 Correct 876 ms 3280 KB Output is correct
56 Correct 886 ms 3220 KB Output is correct
57 Correct 880 ms 3220 KB Output is correct
58 Correct 864 ms 3276 KB Output is correct