# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
722574 | 2023-04-12T11:14:44 Z | PVSekhar | Bank (IZhO14_bank) | C++14 | 107 ms | 262144 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const ll MOD = 1000000007; int main() { freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); int n,m; cin>>n>>m; int a[n],b[m]; for (int i = 0; i < n; i++)cin>>a[i]; for (int i = 0; i < m; i++)cin>>b[i]; vector<pair<int,int>> dp((1<<m),{0,-1});// keeping 'a' fixed stores the index till which the first part of the permutaion can be used and what more is needed to pay a[index+1] dp[0].second=a[0]; bool check=false; pair<int,int> p; for (int i = 1; i < (1<<m); i++) { for (int j = 0; j < m; j++) { if(i&(1<<j)){ p=dp[i^(1<<j)]; // cout<<i<<j<<endl; if(p.second<b[j])continue; p.second-=b[j]; // cout<<i<<" "<<j<<p.first<<" "<<p.second<<endl; if(p.second==0){ p.first++; if(p.first==n){ check=true; dp[i]=p; break; } p.second=a[p.first]; } if(p.first>=dp[i].first){ dp[i]=p; } } } } if(check){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 107 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 98 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 101 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 107 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |