# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
330382 |
2020-11-25T04:41:27 Z |
Vince729 |
Bank (IZhO14_bank) |
C++11 |
|
1000 ms |
86636 KB |
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<complex>
using namespace std;
typedef long long ll;
typedef complex<double> pt;
#define x() real()
#define y() imag()
#define smx(a, b) a = max(a, b)
#define smn(a, b) a = min(a, b)
#define in(mp, v) mp.find(v) != mp.end()
const int MAXN = 20;
const int MOD = 1000000007;
int n, m, a[MAXN+1], b[MAXN];
int dp[MAXN+1][1<<MAXN];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int j = 0; j < m; j++) cin >> b[j];
memset(dp, 0xbf, sizeof(dp));
dp[0][0] = 0;
bool found = false;
for (int i = 1; i <= n; i++) {
found = false;
for (int k = 0; k < (1<<m); k++) {
if (dp[i-1][k] == a[i-1]) {
dp[i][k] = 0;
} else {
for (int j = 0; j < m; j++) {
if (k & (1<<j)) {
int nv = dp[i][k ^ (1<<j)] + b[j];
if (nv <= a[i]) smx(dp[i][k], nv);
}
}
}
if (dp[i][k] == a[i]) found = true;
//cout << k << " " << dp[i][k] << endl;
}
}
if (found) {
cout << "YES" << endl;
} else cout << "NO" << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
86508 KB |
Output is correct |
2 |
Correct |
40 ms |
86508 KB |
Output is correct |
3 |
Correct |
41 ms |
86508 KB |
Output is correct |
4 |
Correct |
57 ms |
86508 KB |
Output is correct |
5 |
Correct |
113 ms |
86508 KB |
Output is correct |
6 |
Correct |
41 ms |
86508 KB |
Output is correct |
7 |
Correct |
42 ms |
86508 KB |
Output is correct |
8 |
Correct |
127 ms |
86508 KB |
Output is correct |
9 |
Correct |
109 ms |
86508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
86508 KB |
Output is correct |
2 |
Correct |
41 ms |
86508 KB |
Output is correct |
3 |
Correct |
42 ms |
86508 KB |
Output is correct |
4 |
Correct |
40 ms |
86508 KB |
Output is correct |
5 |
Correct |
41 ms |
86508 KB |
Output is correct |
6 |
Correct |
41 ms |
86508 KB |
Output is correct |
7 |
Correct |
41 ms |
86508 KB |
Output is correct |
8 |
Correct |
40 ms |
86508 KB |
Output is correct |
9 |
Correct |
48 ms |
86508 KB |
Output is correct |
10 |
Correct |
42 ms |
86508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
86508 KB |
Output is correct |
2 |
Correct |
43 ms |
86508 KB |
Output is correct |
3 |
Correct |
51 ms |
86508 KB |
Output is correct |
4 |
Correct |
54 ms |
86508 KB |
Output is correct |
5 |
Correct |
49 ms |
86508 KB |
Output is correct |
6 |
Correct |
46 ms |
86508 KB |
Output is correct |
7 |
Correct |
45 ms |
86508 KB |
Output is correct |
8 |
Correct |
44 ms |
86508 KB |
Output is correct |
9 |
Correct |
48 ms |
86508 KB |
Output is correct |
10 |
Correct |
48 ms |
86508 KB |
Output is correct |
11 |
Correct |
53 ms |
86508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
86508 KB |
Output is correct |
2 |
Correct |
40 ms |
86508 KB |
Output is correct |
3 |
Correct |
41 ms |
86508 KB |
Output is correct |
4 |
Correct |
57 ms |
86508 KB |
Output is correct |
5 |
Correct |
113 ms |
86508 KB |
Output is correct |
6 |
Correct |
41 ms |
86508 KB |
Output is correct |
7 |
Correct |
42 ms |
86508 KB |
Output is correct |
8 |
Correct |
127 ms |
86508 KB |
Output is correct |
9 |
Correct |
109 ms |
86508 KB |
Output is correct |
10 |
Correct |
41 ms |
86508 KB |
Output is correct |
11 |
Correct |
41 ms |
86508 KB |
Output is correct |
12 |
Correct |
42 ms |
86508 KB |
Output is correct |
13 |
Correct |
40 ms |
86508 KB |
Output is correct |
14 |
Correct |
41 ms |
86508 KB |
Output is correct |
15 |
Correct |
41 ms |
86508 KB |
Output is correct |
16 |
Correct |
41 ms |
86508 KB |
Output is correct |
17 |
Correct |
40 ms |
86508 KB |
Output is correct |
18 |
Correct |
48 ms |
86508 KB |
Output is correct |
19 |
Correct |
42 ms |
86508 KB |
Output is correct |
20 |
Correct |
46 ms |
86508 KB |
Output is correct |
21 |
Correct |
43 ms |
86508 KB |
Output is correct |
22 |
Correct |
51 ms |
86508 KB |
Output is correct |
23 |
Correct |
54 ms |
86508 KB |
Output is correct |
24 |
Correct |
49 ms |
86508 KB |
Output is correct |
25 |
Correct |
46 ms |
86508 KB |
Output is correct |
26 |
Correct |
45 ms |
86508 KB |
Output is correct |
27 |
Correct |
44 ms |
86508 KB |
Output is correct |
28 |
Correct |
48 ms |
86508 KB |
Output is correct |
29 |
Correct |
48 ms |
86508 KB |
Output is correct |
30 |
Correct |
53 ms |
86508 KB |
Output is correct |
31 |
Correct |
191 ms |
86508 KB |
Output is correct |
32 |
Correct |
264 ms |
86508 KB |
Output is correct |
33 |
Correct |
543 ms |
86508 KB |
Output is correct |
34 |
Correct |
744 ms |
86636 KB |
Output is correct |
35 |
Correct |
813 ms |
86636 KB |
Output is correct |
36 |
Execution timed out |
1079 ms |
86508 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |