제출 #1122325

#제출 시각아이디문제언어결과실행 시간메모리
1122325noyancanturk은행 (IZhO14_bank)C++17
71 / 100
32 ms12888 KiB
#ifndef Local #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #endif #include <bits/stdc++.h> #define pb push_back #define lim 100000 using namespace std; void solve(){ 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]; } int dp[1<<m],left[1<<m]; int lll[1<<m]; for(int i=0;i<m;i++){ lll[1<<i]=i; } dp[0]=left[0]=0; for(int i=1;i<(1<<m);i++){ dp[i]=-1; left[i]=INT_MAX; int j=i; while(j){ int k=j&-j; j^=k; if(dp[i]<dp[i^k]){ dp[i]=dp[i^k]; left[i]=left[i^k]+b[lll[k]]; if(left[i]<=a[dp[i]])break; } } if(i!=n&&left[i]==a[dp[i]]){ dp[i]++; left[i]=0; } } /* for(int i=0;i<(1<<m);i++){ cerr<<dp[i].first<<" "<<dp[i].second<<"\n"; } */ if(dp[(1<<m)-1]==n){ cout<<"YES\n"; }else{ cout<<"NO\n"; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #ifdef Local freopen(".in","r",stdin); freopen(".out","w",stdout); #endif int t=1; //cin>>t; while (t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...