# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
717751 | tigar | Bank (IZhO14_bank) | C++14 | 117 ms | 8672 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];
int n, m;
pair<int, int>dp[(1<<21)];
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];
bool dobraa=false;
for(int i=0; i<(1<<m); i++)
{
if(dp[i].first==n){dobraa=true; break;}
for(int j=0; j<m; j++)
{
if(((1<<j)&i))continue;
pair<int, int>pp;
if(people[dp[i].first]==dp[i].second+pay[j]){pp={dp[i].first+1, 0};}
else pp={dp[i].first, dp[i].second+pay[j]};
dp[(i|(1<<j))]=max(pp, dp[(i|(1<<j))]);
}
}
if(dobraa)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... |