Submission #88429

# Submission time Handle Problem Language Result Execution time Memory
88429 2018-12-05T21:28:33 Z xiaowuc1 Bank (IZhO14_bank) C++14
71 / 100
1000 ms 17032 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, m;
int val[20];
int bases[20];
vector<int> masks[1001];
void solve() {
  cin >> n >> m;
  for(int i = 0; i < n; i++) cin >> val[i];
  sort(val, val+n);
  reverse(val, val+n);
  for(int i = 0; i < m; i++) cin >> bases[i];
  for(int mask = 1; mask < (1<<m); mask++) {
    int v = 0;
    for(int i = 0; v <= 1000 && i < m; i++) {
      if((mask&(1<<i))) v += bases[i];
    }
    if(v <= 1000) masks[v].push_back(mask);
  }
  unordered_set<int> ret;
  ret.insert(0);
  for(int i = 0; i < n; i++) {
    unordered_set<int> nret;
    for(int out2: ret) {
      for(int out: masks[val[i]]) {
        if(out&out2) continue;
        if(__builtin_popcount(out | out2) + (n-i-1) > m) continue;
        nret.insert(out | out2);
      }
    }
    ret = nret;
  }
  if(ret.empty()) cout << "NO\n";
  else cout << "YES\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 4 ms 584 KB Output is correct
5 Correct 75 ms 6728 KB Output is correct
6 Correct 2 ms 6728 KB Output is correct
7 Correct 2 ms 6728 KB Output is correct
8 Correct 78 ms 6728 KB Output is correct
9 Correct 74 ms 6728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6728 KB Output is correct
2 Correct 2 ms 6728 KB Output is correct
3 Correct 2 ms 6728 KB Output is correct
4 Correct 2 ms 6728 KB Output is correct
5 Correct 2 ms 6728 KB Output is correct
6 Correct 2 ms 6728 KB Output is correct
7 Correct 2 ms 6728 KB Output is correct
8 Correct 2 ms 6728 KB Output is correct
9 Correct 2 ms 6728 KB Output is correct
10 Correct 2 ms 6728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6728 KB Output is correct
2 Correct 3 ms 6728 KB Output is correct
3 Correct 2 ms 6728 KB Output is correct
4 Correct 3 ms 6728 KB Output is correct
5 Correct 3 ms 6728 KB Output is correct
6 Correct 2 ms 6728 KB Output is correct
7 Correct 3 ms 6728 KB Output is correct
8 Correct 2 ms 6728 KB Output is correct
9 Correct 2 ms 6728 KB Output is correct
10 Correct 2 ms 6728 KB Output is correct
11 Correct 3 ms 6728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 4 ms 584 KB Output is correct
5 Correct 75 ms 6728 KB Output is correct
6 Correct 2 ms 6728 KB Output is correct
7 Correct 2 ms 6728 KB Output is correct
8 Correct 78 ms 6728 KB Output is correct
9 Correct 74 ms 6728 KB Output is correct
10 Correct 2 ms 6728 KB Output is correct
11 Correct 2 ms 6728 KB Output is correct
12 Correct 2 ms 6728 KB Output is correct
13 Correct 2 ms 6728 KB Output is correct
14 Correct 2 ms 6728 KB Output is correct
15 Correct 2 ms 6728 KB Output is correct
16 Correct 2 ms 6728 KB Output is correct
17 Correct 2 ms 6728 KB Output is correct
18 Correct 2 ms 6728 KB Output is correct
19 Correct 2 ms 6728 KB Output is correct
20 Correct 2 ms 6728 KB Output is correct
21 Correct 3 ms 6728 KB Output is correct
22 Correct 2 ms 6728 KB Output is correct
23 Correct 3 ms 6728 KB Output is correct
24 Correct 3 ms 6728 KB Output is correct
25 Correct 2 ms 6728 KB Output is correct
26 Correct 3 ms 6728 KB Output is correct
27 Correct 2 ms 6728 KB Output is correct
28 Correct 2 ms 6728 KB Output is correct
29 Correct 2 ms 6728 KB Output is correct
30 Correct 3 ms 6728 KB Output is correct
31 Correct 72 ms 6728 KB Output is correct
32 Correct 159 ms 6728 KB Output is correct
33 Correct 53 ms 6728 KB Output is correct
34 Correct 11 ms 6728 KB Output is correct
35 Correct 11 ms 6728 KB Output is correct
36 Correct 12 ms 6728 KB Output is correct
37 Correct 33 ms 6728 KB Output is correct
38 Correct 50 ms 6728 KB Output is correct
39 Correct 249 ms 17032 KB Output is correct
40 Correct 65 ms 17032 KB Output is correct
41 Correct 45 ms 17032 KB Output is correct
42 Correct 80 ms 17032 KB Output is correct
43 Correct 62 ms 17032 KB Output is correct
44 Correct 8 ms 17032 KB Output is correct
45 Correct 81 ms 17032 KB Output is correct
46 Correct 68 ms 17032 KB Output is correct
47 Correct 13 ms 17032 KB Output is correct
48 Correct 77 ms 17032 KB Output is correct
49 Correct 75 ms 17032 KB Output is correct
50 Correct 89 ms 17032 KB Output is correct
51 Correct 98 ms 17032 KB Output is correct
52 Correct 404 ms 17032 KB Output is correct
53 Execution timed out 1080 ms 17032 KB Time limit exceeded
54 Halted 0 ms 0 KB -