Submission #800387

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8003872023-08-01 14:06:03ttamxBank (IZhO14_bank)C++14
100 / 100
102 ms8532 KiB
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> p2;
const int N=25;
const int K=(1<<20)+5;
int n,m;
int a[N],b[N];
p2 dp[K];
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> m;
for(int i=0;i<n;i++)cin >> a[i];
for(int i=0;i<m;i++)cin >> b[i];
for(int i=1;i<1<<m;i++)dp[i]={-1,-1};
dp[0]={0,0};
for(int i=1;i<1<<m;i++){
for(int j=0;j<m;j++){
if(!(i>>j&1))continue;
int u=i^(1<<j);
auto [id,val]=dp[u];
if(id==-1)continue;
if(val+b[j]==a[id]){
dp[i]={id+1,0};
}else if(val+b[j]<a[id]){
dp[i]={id,val+b[j]};
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:25:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |             auto [id,val]=dp[u];
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...