# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
68543 |
2018-08-17T09:27:01 Z |
quoriess |
Bank (IZhO14_bank) |
C++14 |
|
1000 ms |
3936 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
int n,m;
cin>>n>>m;
vector<int> salary,banks;
for (int i = 0; i < n; i++)
{
int a;
cin>>a;
salary.push_back(a);
}
for (int j = 0; j < m; j++)
{
int a;
cin>>a;
banks.push_back(a);
}
/*
2 4
3 6
5 1 2 1
*/
vector<vector<bitset<20> > > sncler(n,vector<bitset<20> >());
for (int i = 0; i < 1<<m; i++)
{
bitset<20> smd(i);
int tplm=0;
for (int j = 0; j < m; j++)
{
if(smd[j])
tplm+=banks[j];
}
for(int j=0;j<n;j++){
if(salary[j]==tplm)
sncler[j].push_back(smd);
}
}
int mstb=1<<m;
bool dp[n][mstb];
for(int i=0;i<n;i++){
for(int j=0;j<mstb;j++)dp[i][j]=0;
}
for(auto j:sncler[0])dp[0][j.to_ulong()]=1;
for (int i = 1; i < n; i++)
{
for(int k=0;k<mstb;k++){
for (auto j: sncler[i])
{
if((k&j.to_ulong())==0){
dp[i][k^j.to_ulong()]=dp[i-1][k]||dp[i][k^j.to_ulong()];
}
}
}
}
bool ans=0;
for(int i=1;i<mstb;i++)if(dp[n-1][i])ans=true;
cout << (ans?"YES":"NO")<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
372 KB |
Output is correct |
4 |
Correct |
3 ms |
464 KB |
Output is correct |
5 |
Correct |
72 ms |
1380 KB |
Output is correct |
6 |
Correct |
2 ms |
1380 KB |
Output is correct |
7 |
Correct |
2 ms |
1380 KB |
Output is correct |
8 |
Correct |
72 ms |
1680 KB |
Output is correct |
9 |
Correct |
73 ms |
1680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1680 KB |
Output is correct |
2 |
Correct |
2 ms |
1680 KB |
Output is correct |
3 |
Correct |
2 ms |
1680 KB |
Output is correct |
4 |
Correct |
2 ms |
1680 KB |
Output is correct |
5 |
Correct |
2 ms |
1680 KB |
Output is correct |
6 |
Correct |
2 ms |
1680 KB |
Output is correct |
7 |
Correct |
2 ms |
1680 KB |
Output is correct |
8 |
Correct |
2 ms |
1680 KB |
Output is correct |
9 |
Correct |
2 ms |
1680 KB |
Output is correct |
10 |
Correct |
2 ms |
1680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1680 KB |
Output is correct |
2 |
Correct |
3 ms |
1680 KB |
Output is correct |
3 |
Correct |
3 ms |
1680 KB |
Output is correct |
4 |
Correct |
5 ms |
1680 KB |
Output is correct |
5 |
Correct |
4 ms |
1680 KB |
Output is correct |
6 |
Correct |
3 ms |
1680 KB |
Output is correct |
7 |
Correct |
3 ms |
1680 KB |
Output is correct |
8 |
Correct |
3 ms |
1680 KB |
Output is correct |
9 |
Correct |
3 ms |
1680 KB |
Output is correct |
10 |
Correct |
3 ms |
1680 KB |
Output is correct |
11 |
Correct |
3 ms |
1680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
372 KB |
Output is correct |
4 |
Correct |
3 ms |
464 KB |
Output is correct |
5 |
Correct |
72 ms |
1380 KB |
Output is correct |
6 |
Correct |
2 ms |
1380 KB |
Output is correct |
7 |
Correct |
2 ms |
1380 KB |
Output is correct |
8 |
Correct |
72 ms |
1680 KB |
Output is correct |
9 |
Correct |
73 ms |
1680 KB |
Output is correct |
10 |
Correct |
2 ms |
1680 KB |
Output is correct |
11 |
Correct |
2 ms |
1680 KB |
Output is correct |
12 |
Correct |
2 ms |
1680 KB |
Output is correct |
13 |
Correct |
2 ms |
1680 KB |
Output is correct |
14 |
Correct |
2 ms |
1680 KB |
Output is correct |
15 |
Correct |
2 ms |
1680 KB |
Output is correct |
16 |
Correct |
2 ms |
1680 KB |
Output is correct |
17 |
Correct |
2 ms |
1680 KB |
Output is correct |
18 |
Correct |
2 ms |
1680 KB |
Output is correct |
19 |
Correct |
2 ms |
1680 KB |
Output is correct |
20 |
Correct |
3 ms |
1680 KB |
Output is correct |
21 |
Correct |
3 ms |
1680 KB |
Output is correct |
22 |
Correct |
3 ms |
1680 KB |
Output is correct |
23 |
Correct |
5 ms |
1680 KB |
Output is correct |
24 |
Correct |
4 ms |
1680 KB |
Output is correct |
25 |
Correct |
3 ms |
1680 KB |
Output is correct |
26 |
Correct |
3 ms |
1680 KB |
Output is correct |
27 |
Correct |
3 ms |
1680 KB |
Output is correct |
28 |
Correct |
3 ms |
1680 KB |
Output is correct |
29 |
Correct |
3 ms |
1680 KB |
Output is correct |
30 |
Correct |
3 ms |
1680 KB |
Output is correct |
31 |
Correct |
983 ms |
2784 KB |
Output is correct |
32 |
Execution timed out |
1068 ms |
3936 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |