Submission #1010910

#TimeUsernameProblemLanguageResultExecution timeMemory
1010910lsdwpqerBank (IZhO14_bank)C++14
100 / 100
108 ms16984 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ ll n,m; cin >> n >> m; ll a[n],b[m]; for(int i = 0;i< n;i++)cin >> a[i]; for(int i = 0;i< m;i++)cin >> b[i]; ll dp[1<<m][2]; for(int i = 0;i< (1<<m);i++){ ll p = i; ll k = 0; dp[i][0] = 0; dp[i][1] = 0; while(p > 0){ if(p%2 == 1){ ll x = dp[i][0]; ll y = dp[i-(1<<k)][0]; ll u = dp[i][1]; ll v = dp[i-(1<<k)][1]; if(x < y+1 && v+b[k] == a[y]){ dp[i][0] = y+1; dp[i][1] = 0; } if(x < y && v+b[k] < a[y]){ dp[i][0] = y; dp[i][1] = v+b[k]; } if(x == y && v+b[k] < a[y]){ dp[i][1] = max(v+b[k],u); } } p/=2; k++; } } ll res = 0; for(int i = 0;i <(1<<m);i++){ res = max(res,dp[i][0]); } if(res == n)cout << "YES" << endl; else cout << "NO" << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...