제출 #442626

#제출 시각아이디문제언어결과실행 시간메모리
442626leaked은행 (IZhO14_bank)C++14
19 / 100
1095 ms332 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("-O3") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define vec vector #define sz(x) ( int)x.size() #define m_p make_pair #define f first #define s second #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() using namespace std; typedef long long ll; typedef pair<ll, int> pli; typedef pair<int,ll> pil; typedef pair<int,int> pii; typedef unsigned long long ull; auto rng=bind(uniform_int_distribution<int>(1,1000),mt19937(time(0))); template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);} template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);} const int Mx=1e3; const int N=21; //vec<int> w[Mx]; int dp[21][1<<N]; int a[N],b[N],n,m; void rec(int i,int x,int j,int mask){ if(i==n){ cout<<"YES"; exit(0); } if(j==m){ if(x) return; if(x==0){ if(!dp[i+1][mask]){ dp[i+1][mask]=1; rec(i+1,a[i+1],0,mask); } } } if((1<<j)&mask) rec(i,x,j+1,mask); else{ if(x>=b[j]) rec(i,x-b[j],j+1,mask|(1<<j)); rec(i,x,j+1,mask); } } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // int n,m; // n=20;m=20; cin>>n>>m; for(int i=0;i<n;i++) cin>>a[i]; for(int j=0;j<m;j++){ cin>>b[j]; } rec(0,a[0],0,0); cout<<"NO"; return 0; } /* 1 5 8 4 2 5 1 3 2 4 4 5 2 2 1 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...