# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
10636 | 2014-10-30T08:52:34 Z | gs14004 | Bank (IZhO14_bank) | C++ | 1000 ms | 828 KB |
#include <cstdio> #include <vector> using namespace std; vector<int> a_bit[20]; int n,m,a[20],b[20]; void trial_bit(int v){ int res = 0; for (int i=0; i<m; i++) { if((v>>i)&1) res += b[i]; } for (int i=0; i<n; i++) { if(a[i] == res) a_bit[i].push_back(v); } } int f(int pos, int v){ if(pos == n) return 1; for (int i=0; i<a_bit[pos].size(); i++) { if((a_bit[pos][i] & ~v) == 0 && f(pos+1,v^a_bit[pos][i])) return 1; } return 0; } int main(){ scanf("%d %d",&n,&m); for (int i=0; i<n; i++) { scanf("%d",&a[i]); } for (int i=0; i<m; i++) { scanf("%d",&b[i]); } for (int i=0; i<(1<<m); i++) { trial_bit(i); } printf(f(0,(1<<m)-1)?"YES":"NO"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 4 ms | 440 KB | Output is correct |
5 | Correct | 71 ms | 440 KB | Output is correct |
6 | Correct | 2 ms | 500 KB | Output is correct |
7 | Correct | 2 ms | 500 KB | Output is correct |
8 | Correct | 72 ms | 576 KB | Output is correct |
9 | Correct | 70 ms | 576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 576 KB | Output is correct |
2 | Correct | 2 ms | 592 KB | Output is correct |
3 | Correct | 2 ms | 592 KB | Output is correct |
4 | Correct | 2 ms | 592 KB | Output is correct |
5 | Correct | 2 ms | 664 KB | Output is correct |
6 | Correct | 2 ms | 664 KB | Output is correct |
7 | Correct | 2 ms | 664 KB | Output is correct |
8 | Correct | 2 ms | 664 KB | Output is correct |
9 | Correct | 2 ms | 664 KB | Output is correct |
10 | Correct | 2 ms | 664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 664 KB | Output is correct |
2 | Correct | 3 ms | 664 KB | Output is correct |
3 | Correct | 3 ms | 664 KB | Output is correct |
4 | Correct | 3 ms | 664 KB | Output is correct |
5 | Correct | 3 ms | 664 KB | Output is correct |
6 | Correct | 3 ms | 664 KB | Output is correct |
7 | Correct | 2 ms | 664 KB | Output is correct |
8 | Correct | 2 ms | 664 KB | Output is correct |
9 | Correct | 3 ms | 664 KB | Output is correct |
10 | Correct | 3 ms | 664 KB | Output is correct |
11 | Correct | 3 ms | 664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 4 ms | 440 KB | Output is correct |
5 | Correct | 71 ms | 440 KB | Output is correct |
6 | Correct | 2 ms | 500 KB | Output is correct |
7 | Correct | 2 ms | 500 KB | Output is correct |
8 | Correct | 72 ms | 576 KB | Output is correct |
9 | Correct | 70 ms | 576 KB | Output is correct |
10 | Correct | 2 ms | 576 KB | Output is correct |
11 | Correct | 2 ms | 592 KB | Output is correct |
12 | Correct | 2 ms | 592 KB | Output is correct |
13 | Correct | 2 ms | 592 KB | Output is correct |
14 | Correct | 2 ms | 664 KB | Output is correct |
15 | Correct | 2 ms | 664 KB | Output is correct |
16 | Correct | 2 ms | 664 KB | Output is correct |
17 | Correct | 2 ms | 664 KB | Output is correct |
18 | Correct | 2 ms | 664 KB | Output is correct |
19 | Correct | 2 ms | 664 KB | Output is correct |
20 | Correct | 3 ms | 664 KB | Output is correct |
21 | Correct | 3 ms | 664 KB | Output is correct |
22 | Correct | 3 ms | 664 KB | Output is correct |
23 | Correct | 3 ms | 664 KB | Output is correct |
24 | Correct | 3 ms | 664 KB | Output is correct |
25 | Correct | 3 ms | 664 KB | Output is correct |
26 | Correct | 2 ms | 664 KB | Output is correct |
27 | Correct | 2 ms | 664 KB | Output is correct |
28 | Correct | 3 ms | 664 KB | Output is correct |
29 | Correct | 3 ms | 664 KB | Output is correct |
30 | Correct | 3 ms | 664 KB | Output is correct |
31 | Correct | 71 ms | 664 KB | Output is correct |
32 | Correct | 72 ms | 828 KB | Output is correct |
33 | Correct | 76 ms | 828 KB | Output is correct |
34 | Correct | 79 ms | 828 KB | Output is correct |
35 | Correct | 80 ms | 828 KB | Output is correct |
36 | Correct | 86 ms | 828 KB | Output is correct |
37 | Correct | 71 ms | 828 KB | Output is correct |
38 | Correct | 75 ms | 828 KB | Output is correct |
39 | Correct | 76 ms | 828 KB | Output is correct |
40 | Correct | 79 ms | 828 KB | Output is correct |
41 | Correct | 87 ms | 828 KB | Output is correct |
42 | Correct | 120 ms | 828 KB | Output is correct |
43 | Correct | 77 ms | 828 KB | Output is correct |
44 | Correct | 83 ms | 828 KB | Output is correct |
45 | Correct | 74 ms | 828 KB | Output is correct |
46 | Correct | 77 ms | 828 KB | Output is correct |
47 | Correct | 83 ms | 828 KB | Output is correct |
48 | Correct | 70 ms | 828 KB | Output is correct |
49 | Correct | 76 ms | 828 KB | Output is correct |
50 | Correct | 87 ms | 828 KB | Output is correct |
51 | Correct | 81 ms | 828 KB | Output is correct |
52 | Correct | 78 ms | 828 KB | Output is correct |
53 | Correct | 78 ms | 828 KB | Output is correct |
54 | Correct | 86 ms | 828 KB | Output is correct |
55 | Correct | 86 ms | 828 KB | Output is correct |
56 | Correct | 86 ms | 828 KB | Output is correct |
57 | Execution timed out | 1079 ms | 828 KB | Time limit exceeded |
58 | Halted | 0 ms | 0 KB | - |