답안 #536403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
536403 2022-03-13T07:51:23 Z blue 은행 (IZhO14_bank) C++17
100 / 100
126 ms 8540 KB
#include <iostream>
#include <vector>
using namespace std;

using vi = vector<int>;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int N, M;
	cin >> N >> M;

	vi A(1+N, 0);
	for(int i = 1; i <= N; i++)
	{
		cin >> A[i];
		A[i] += A[i-1];
	}

	vi b(M, 0);
	for(int j = 0; j < M; j++)
		cin >> b[j];

	vi s((1<<M), 0);

	for(int j = 0; j < M; j++)
		for(int m = 0; m < (1<<M); m++)
			if(m & (1 << j))
				s[m] += b[j];

	vi dp((1<<M), 0);
	dp[0] = 1;

	for(int m = 0; m < (1<<M); m++)
	{
		if(!dp[m]) continue;

		int i = 0;
		while(i+1 <= N && A[i+1] <= s[m])
			i++;

		if(i == N)
		{
			cout << "YES\n";
			return 0;
		}

		for(int z = 0; z < M; z++)
		{
			if(m & (1<<z)) continue;
			if(s[m] + b[z] <= A[i+1])
				dp[m | (1 << z)] = 1;
		}
	}

	cout << "NO\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 27 ms 8516 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 30 ms 8528 KB Output is correct
9 Correct 83 ms 8532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 452 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 27 ms 8516 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 30 ms 8528 KB Output is correct
9 Correct 83 ms 8532 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 452 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 108 ms 8408 KB Output is correct
32 Correct 95 ms 8532 KB Output is correct
33 Correct 27 ms 8536 KB Output is correct
34 Correct 23 ms 8516 KB Output is correct
35 Correct 22 ms 8396 KB Output is correct
36 Correct 21 ms 8536 KB Output is correct
37 Correct 24 ms 8528 KB Output is correct
38 Correct 24 ms 8400 KB Output is correct
39 Correct 25 ms 8532 KB Output is correct
40 Correct 20 ms 8536 KB Output is correct
41 Correct 21 ms 8516 KB Output is correct
42 Correct 67 ms 8396 KB Output is correct
43 Correct 23 ms 8516 KB Output is correct
44 Correct 21 ms 8536 KB Output is correct
45 Correct 20 ms 8524 KB Output is correct
46 Correct 45 ms 8512 KB Output is correct
47 Correct 23 ms 8528 KB Output is correct
48 Correct 32 ms 8528 KB Output is correct
49 Correct 20 ms 8536 KB Output is correct
50 Correct 95 ms 8532 KB Output is correct
51 Correct 22 ms 8532 KB Output is correct
52 Correct 24 ms 8540 KB Output is correct
53 Correct 96 ms 8528 KB Output is correct
54 Correct 105 ms 8404 KB Output is correct
55 Correct 126 ms 8400 KB Output is correct
56 Correct 90 ms 8512 KB Output is correct
57 Correct 92 ms 8536 KB Output is correct
58 Correct 90 ms 8532 KB Output is correct