# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68464 | ege_eksi | Bank (IZhO14_bank) | C++14 | 1072 ms | 616 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int n , m;
int a[20];
int b[20];
int cnt[1001];
bool f(int index)
{
if(index == n)
{
return true;
}
//printf("%d\n",a[index]);
if(a[index] == 0)
{
return f(index+1);
}
for(int i = a[index] ; i > 0 ; i--)
{
if(cnt[i] > 0)
{
cnt[i]--;
a[index] -= i;
if(f(index) == true)
{
return true;
}
a[index] += i;
cnt[i]++;
}
}
return false;
}
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]);
cnt[b[i]]++;
}
if(f(0) == true)
{
printf("YES");
}
else
{
printf("NO");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |