# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991271 | hippo123 | Bank (IZhO14_bank) | C++17 | 1 ms | 348 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;
#define pr pair<int, int>
#define ll long long
#define pb push_back
#define f first
#define s second
int main(){
freopen("bank.in", "r", stdin);
freopen("bank.out", "w", stdout);
int n, m; cin>>n>>m;
vector<int> a(n), b(m);
for (auto &e: a) cin>>e;
for (auto &e: b) cin>>e;
vector<pr> dp(1<<m);
dp[0]={0, 0};
for (int x=0; x<(1<<m); x++){
for (int i=0; i<m; i++){
if(x&(1<<i)) continue;
pr node;
if(a[dp[x].f]==dp[x].s+b[i]) node={dp[x].f+1, 0};
else {
node={dp[x].f, dp[x].s+b[i]};
}
dp[x|(1<<i)]=max(dp[x|(1<<i)], node);
}
}
if(dp[(1<<m)-1].f==n) cout<<"YES"<<endl;
cout<<"NO";
}
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... |