# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
246546 |
2020-07-09T14:47:47 Z |
aloo123 |
Bank (IZhO14_bank) |
C++14 |
|
292 ms |
82572 KB |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/trie_policy.hpp>
#define ll int
#define endl "\n"
// #define int
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
// const ll INF = 1e12;
const ll N =(22); // TODO : change value as per problem
// const ll MOD = 1e9+7;
ll a[N];
ll b[N];
vector<ll> nice[N];
ll dp[N][(1<<22) + 5];
ll n,m;
inline ll recurse(ll i,ll j){
if(i > n) {
cout << "YES\n";
exit(0);
}
if(dp[i][j]!=-1) return dp[i][j];
for(auto k:nice[i]){
if(!(k & j) && recurse(i+1,j ^ k)) {
return dp[i][j] = 1;
}
}
return dp[i][j] = 0;
}
void solve(){
cin >> n >> m;
for(int i = 1;i<=n;i++) cin >> a[i];
for(int i= 1;i<=m;i++) cin >> b[i];
for( int i = 0 ; i < ( 1<<m ) ; i++ ) {
int sum = 0;
for( int j = 0 ; j < m ; j++ ) if( i & ( 1<<j ) ) sum += b[j+1];
for( int j = 0 ; j < n ; j++ ) if( a[j+1] == sum ) nice[j+1].emplace_back( i );
}
for(int i =1;i<=n;i++){
for(int j =0;j<(1<<m);j++) dp[i][j] = -1;
}
bool gg = recurse(1,0);
if(gg) cout << "YES\n";
else cout << "NO\n";
// cout << recurse(1,0) << endl;
// cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
ll tt=1;
while(tt--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
512 KB |
Output is correct |
5 |
Correct |
71 ms |
4472 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
71 ms |
4472 KB |
Output is correct |
9 |
Correct |
72 ms |
4472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
896 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
6 ms |
1024 KB |
Output is correct |
4 |
Correct |
6 ms |
1408 KB |
Output is correct |
5 |
Correct |
6 ms |
1024 KB |
Output is correct |
6 |
Correct |
6 ms |
768 KB |
Output is correct |
7 |
Correct |
6 ms |
640 KB |
Output is correct |
8 |
Correct |
6 ms |
512 KB |
Output is correct |
9 |
Correct |
6 ms |
896 KB |
Output is correct |
10 |
Correct |
6 ms |
1024 KB |
Output is correct |
11 |
Correct |
6 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
512 KB |
Output is correct |
5 |
Correct |
71 ms |
4472 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
71 ms |
4472 KB |
Output is correct |
9 |
Correct |
72 ms |
4472 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
6 ms |
896 KB |
Output is correct |
21 |
Correct |
6 ms |
512 KB |
Output is correct |
22 |
Correct |
6 ms |
1024 KB |
Output is correct |
23 |
Correct |
6 ms |
1408 KB |
Output is correct |
24 |
Correct |
6 ms |
1024 KB |
Output is correct |
25 |
Correct |
6 ms |
768 KB |
Output is correct |
26 |
Correct |
6 ms |
640 KB |
Output is correct |
27 |
Correct |
6 ms |
512 KB |
Output is correct |
28 |
Correct |
6 ms |
896 KB |
Output is correct |
29 |
Correct |
6 ms |
1024 KB |
Output is correct |
30 |
Correct |
6 ms |
1408 KB |
Output is correct |
31 |
Correct |
74 ms |
8568 KB |
Output is correct |
32 |
Correct |
78 ms |
12868 KB |
Output is correct |
33 |
Correct |
94 ms |
29176 KB |
Output is correct |
34 |
Correct |
102 ms |
41480 KB |
Output is correct |
35 |
Correct |
115 ms |
45688 KB |
Output is correct |
36 |
Correct |
134 ms |
82552 KB |
Output is correct |
37 |
Correct |
75 ms |
8620 KB |
Output is correct |
38 |
Correct |
81 ms |
16760 KB |
Output is correct |
39 |
Correct |
99 ms |
33300 KB |
Output is correct |
40 |
Correct |
103 ms |
41592 KB |
Output is correct |
41 |
Correct |
130 ms |
82556 KB |
Output is correct |
42 |
Correct |
87 ms |
20856 KB |
Output is correct |
43 |
Correct |
93 ms |
33272 KB |
Output is correct |
44 |
Correct |
126 ms |
62072 KB |
Output is correct |
45 |
Correct |
77 ms |
12664 KB |
Output is correct |
46 |
Correct |
89 ms |
25080 KB |
Output is correct |
47 |
Correct |
117 ms |
62072 KB |
Output is correct |
48 |
Correct |
71 ms |
4472 KB |
Output is correct |
49 |
Correct |
70 ms |
4472 KB |
Output is correct |
50 |
Correct |
133 ms |
82552 KB |
Output is correct |
51 |
Correct |
104 ms |
41592 KB |
Output is correct |
52 |
Correct |
101 ms |
41464 KB |
Output is correct |
53 |
Correct |
106 ms |
41592 KB |
Output is correct |
54 |
Correct |
132 ms |
82572 KB |
Output is correct |
55 |
Correct |
131 ms |
82572 KB |
Output is correct |
56 |
Correct |
133 ms |
82552 KB |
Output is correct |
57 |
Correct |
292 ms |
82552 KB |
Output is correct |
58 |
Correct |
128 ms |
78456 KB |
Output is correct |