Submission #997741

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9977412024-06-12 18:47:33PetrixBank (IZhO14_bank)C++17
100 / 100
73 ms8636 KiB
#include<iostream>
using namespace std;
#define int long long
int a[20],b[20];
int dp[1048577];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m,max1,sum,i,j;
cin>>n>>m;
for(i=0;i<n;i++) {
cin>>a[i];
if(i) a[i]+=a[i-1];
}
for (i=0;i<m;i++)
cin>>b[i];
for(i=0;i<(1<<m);i++) {
max1=-1;sum=0;
for(j=0;j<m;j++){
if(i&(1<<j)){
sum+=b[j];
max1=max(max1,dp[i^(1<<j)]);
}
}
dp[i]=max1;
if(sum==a[max1+1]) dp[i]++;
if(dp[i]==n-1){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...