답안 #331542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
331542 2020-11-28T20:57:06 Z jovan_b 은행 (IZhO14_bank) C++17
100 / 100
555 ms 14956 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

vector <int> maske[1005];
int dp[2000005];
int dpp[2000005];
int a[25];
int b[25];

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

	int n, m;
	cin >> n >> m;
	for(int i=1; i<=n; i++){
        cin >> a[i];
	}
	for(int j=0; j<m; j++){
        cin >> b[j];
	}
	for(int mask=1; mask<(1<<m); mask++){
        int sum = 0;
        for(int j=0; j<m; j++){
            if((1<<j)&mask) sum += b[j];
        }
        if(sum <= 1000) maske[sum].push_back(mask);
	}
	dpp[0] = 1;
	for(int i=0; i<n; i++){
        for(int mask=0; mask<(1<<m); mask++){
            if(!dpp[mask]) continue;
            for(auto c : maske[a[i+1]]){
                if(!(c&mask)) dp[mask|c] = 1;
            }
        }
        for(int mask=0; mask<(1<<m); mask++){
            dpp[mask] = dp[mask];
            dp[mask] = 0;
        }
	}
	for(int i=0; i<(1<<m); i++){
        if(dpp[i]){
            cout << "YES\n";
            return 0;
        }
	}
	cout << "NO\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 876 KB Output is correct
5 Correct 82 ms 14956 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 77 ms 14316 KB Output is correct
9 Correct 78 ms 14572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 492 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 3 ms 620 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 3 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 876 KB Output is correct
5 Correct 82 ms 14956 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 77 ms 14316 KB Output is correct
9 Correct 78 ms 14572 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 512 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 2 ms 620 KB Output is correct
24 Correct 3 ms 620 KB Output is correct
25 Correct 2 ms 492 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 620 KB Output is correct
31 Correct 89 ms 13932 KB Output is correct
32 Correct 170 ms 14444 KB Output is correct
33 Correct 86 ms 9452 KB Output is correct
34 Correct 96 ms 8556 KB Output is correct
35 Correct 89 ms 8556 KB Output is correct
36 Correct 103 ms 8556 KB Output is correct
37 Correct 72 ms 8684 KB Output is correct
38 Correct 84 ms 8684 KB Output is correct
39 Correct 122 ms 13632 KB Output is correct
40 Correct 91 ms 10348 KB Output is correct
41 Correct 107 ms 9068 KB Output is correct
42 Correct 91 ms 14060 KB Output is correct
43 Correct 91 ms 10348 KB Output is correct
44 Correct 94 ms 8556 KB Output is correct
45 Correct 84 ms 14728 KB Output is correct
46 Correct 86 ms 11756 KB Output is correct
47 Correct 95 ms 8556 KB Output is correct
48 Correct 78 ms 14316 KB Output is correct
49 Correct 78 ms 14444 KB Output is correct
50 Correct 207 ms 13488 KB Output is correct
51 Correct 95 ms 14572 KB Output is correct
52 Correct 101 ms 13644 KB Output is correct
53 Correct 555 ms 13492 KB Output is correct
54 Correct 223 ms 13356 KB Output is correct
55 Correct 199 ms 13488 KB Output is correct
56 Correct 201 ms 13760 KB Output is correct
57 Correct 216 ms 13632 KB Output is correct
58 Correct 201 ms 13760 KB Output is correct