제출 #864407

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
8644072023-10-22 19:29:02PM1은행 (IZhO14_bank)C++17
71 / 100
129 ms4676 KiB
#include <bits/stdc++.h>
using namespace std;
const int mxn=20;
int n,m,a[mxn],b[mxn],dp[(1<<20)],ps[20];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
ps[i]=ps[i-1]+a[i];
}
for(int i=1;i<=m;i++){
cin>>b[i];
}
for(int mask=1;mask<(1<<m);mask++){
int sum=0;
for(int i=0;i<m;i++){
if(mask&(1<<i)){
sum+=b[i+1];
}
}
for(int i=0;i<m;i++){
if(mask&(1<<i)){
dp[mask]=max(dp[mask],dp[mask-(1<<i)]+(sum==ps[dp[mask-(1<<i)]+1]));
}
}
}
if(dp[(1<<m)-1]==n){
cout<<"YES"<<endl;
}
else{
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...