Submission #330388

# Submission time Handle Problem Language Result Execution time Memory
330388 2020-11-25T04:45:35 Z Vince729 Bank (IZhO14_bank) C++11
71 / 100
1000 ms 86680 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, f1 = false;
    for (int i = 1; i <= n; i++) {
        found = false; f1 = false;
        for (int k = 0; k < (1<<m); k++) {
            if (dp[i-1][k] == a[i-1]) {
                dp[i][k] = 0;
                f1 = true;
            } else {
                if (!f1) continue;
                for (int j = 0; j < m; j++) {
                    if (k & (1<<j)) {
                        smx(dp[i][k], dp[i][k & ~(1<<j)] + b[j]);
                    }
                }
            }
            if (dp[i][k] == a[i]) found = true;
            //cout << k << " " << dp[i][k] << endl;
        }
        if (!found) break;
    }
    if (found) {
        cout << "YES" << endl;
    } else cout << "NO" << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 41 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 43 ms 86508 KB Output is correct
5 Correct 113 ms 86636 KB Output is correct
6 Correct 40 ms 86528 KB Output is correct
7 Correct 41 ms 86508 KB Output is correct
8 Correct 116 ms 86508 KB Output is correct
9 Correct 112 ms 86508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 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 41 ms 86508 KB Output is correct
5 Correct 42 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 41 ms 86508 KB Output is correct
9 Correct 41 ms 86508 KB Output is correct
10 Correct 42 ms 86596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 86508 KB Output is correct
2 Correct 43 ms 86508 KB Output is correct
3 Correct 50 ms 86508 KB Output is correct
4 Correct 42 ms 86508 KB Output is correct
5 Correct 44 ms 86636 KB Output is correct
6 Correct 46 ms 86508 KB Output is correct
7 Correct 46 ms 86508 KB Output is correct
8 Correct 44 ms 86508 KB Output is correct
9 Correct 46 ms 86508 KB Output is correct
10 Correct 45 ms 86508 KB Output is correct
11 Correct 42 ms 86508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 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 43 ms 86508 KB Output is correct
5 Correct 113 ms 86636 KB Output is correct
6 Correct 40 ms 86528 KB Output is correct
7 Correct 41 ms 86508 KB Output is correct
8 Correct 116 ms 86508 KB Output is correct
9 Correct 112 ms 86508 KB Output is correct
10 Correct 41 ms 86508 KB Output is correct
11 Correct 40 ms 86508 KB Output is correct
12 Correct 41 ms 86508 KB Output is correct
13 Correct 41 ms 86508 KB Output is correct
14 Correct 42 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 41 ms 86508 KB Output is correct
18 Correct 41 ms 86508 KB Output is correct
19 Correct 42 ms 86596 KB Output is correct
20 Correct 47 ms 86508 KB Output is correct
21 Correct 43 ms 86508 KB Output is correct
22 Correct 50 ms 86508 KB Output is correct
23 Correct 42 ms 86508 KB Output is correct
24 Correct 44 ms 86636 KB Output is correct
25 Correct 46 ms 86508 KB Output is correct
26 Correct 46 ms 86508 KB Output is correct
27 Correct 44 ms 86508 KB Output is correct
28 Correct 46 ms 86508 KB Output is correct
29 Correct 45 ms 86508 KB Output is correct
30 Correct 42 ms 86508 KB Output is correct
31 Correct 186 ms 86508 KB Output is correct
32 Correct 257 ms 86612 KB Output is correct
33 Correct 494 ms 86636 KB Output is correct
34 Correct 662 ms 86636 KB Output is correct
35 Correct 497 ms 86656 KB Output is correct
36 Correct 604 ms 86508 KB Output is correct
37 Correct 185 ms 86508 KB Output is correct
38 Correct 113 ms 86636 KB Output is correct
39 Correct 603 ms 86636 KB Output is correct
40 Correct 312 ms 86636 KB Output is correct
41 Correct 179 ms 86548 KB Output is correct
42 Correct 387 ms 86572 KB Output is correct
43 Correct 474 ms 86508 KB Output is correct
44 Correct 114 ms 86508 KB Output is correct
45 Correct 259 ms 86508 KB Output is correct
46 Correct 435 ms 86508 KB Output is correct
47 Correct 735 ms 86508 KB Output is correct
48 Correct 113 ms 86508 KB Output is correct
49 Correct 120 ms 86680 KB Output is correct
50 Execution timed out 1089 ms 86508 KB Time limit exceeded
51 Halted 0 ms 0 KB -