# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
717383 | tigar | Bank (IZhO14_bank) | C++14 | 1080 ms | 300 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 <bits/stdc++.h>
using namespace std;
int people[30], pay[30];
bool used[30];
int given[30];
int n, m;
bool rekurzivna(int covek, int k)
{
//cout<<"-->"<<k<<endl;
if(covek==n){return true;}
bool ret=false;
for(int i=0; i<m; i++)
{
if(!used[i])
{
//cout<<i<<endl;
used[i]=true;
given[covek]+=pay[i];
//cout<<i<<" "<<given[covek]<<" "<<people[covek]<<" "<<pay[i]<<endl;
if(given[covek]<people[covek])ret=(ret|rekurzivna(covek, k+1));
else if(given[covek]==people[covek])ret=(ret|rekurzivna(covek+1, k+1));
given[covek]-=pay[i];
used[i]=false;
}
if(ret)break;
}
//cout<<"-->"<<k<<endl;
return ret;
}
int main()
{
#define name "bank"
if(fopen(name".inp", "r")){
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
ios_base::sync_with_stdio(); cin.tie(); cout.tie();
cin>>n>>m;
for(int i=0; i<n; i++)cin>>people[i];
for(int j=0; j<m; j++)cin>>pay[j];
if(rekurzivna(0, 0))cout<<"YES\n";
else cout<<"NO\n";
return 0;
}
/*1 8
9
1 1 1 1 1 1 1 1*/
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... |