# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170056 |
2019-12-23T20:22:03 Z |
itgl |
Bank (IZhO14_bank) |
C++14 |
|
2 ms |
376 KB |
#include<bits/stdc++.h>
using namespace std;
int n, m;
int a[25];
bool solve(int pos, int n1, int b[], int m1, int sum, int cnt){
if(n1-1>m1) return 0;
if(pos==n) return 1;
if(sum==a[pos+1]) return solve(pos+1,n1-1,b,m1-cnt,0,0);
for(int i=1;i<=m;i++){
if(b[i]!=0){
sum+=b[i];
//cout << sum << endl;
if(sum>a[pos+1]) return 0;
int lol=b[i];
b[i]=0;
if(solve(pos,n1,b,m1,sum,cnt+1)) return 1;
b[i]=lol;
sum-=lol;
}
}
return 0;
}
int main(){
cin >> n >> m;
int b[m+1];
for(int i=1;i<=n;i++){
cin >> a[i];
}
for(int j=1;j<=m;j++){
cin >> b[j];
}
sort(a+1,a+n+1);
sort(b+1,b+n+1);
if(solve(0,n,b,m,0,0)) cout << "YES";
else cout << "NO";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |