Submission #170028

#TimeUsernameProblemLanguageResultExecution timeMemory
170028itglBank (IZhO14_bank)C++14
0 / 100
2 ms384 KiB
#include<bits/stdc++.h> using namespace std; int n; int an[25]; bool check(int pos,int m, int am[]){ if(n-pos>m) return 0; if(pos==n) return 1; //cout << n << ' ' << an[pos+1] << endl; for(int i=1; i<=an[pos+1]; i++){ int c=0; if(am[i]>0&&am[an[pos+1]-i]>0){ //cout << am[i] << ' ' << am[an[pos+1]-i]<<endl; //cout << i << ' ' << an[pos+1]-i << endl; am[i]--; c++; am[an[pos+1]-i]--; if(am[i]<0) break; //cout << am[i] << endl; if(an[pos+1]-i!=0)c++; if(check(pos+1,m-c,am)) return 1; am[i]++; am[an[pos]-i]++; } } return 0; } int main(){ int m; cin >> n >> m; int am[1005]; memset(am,0,sizeof(am)); for(int i=1;i<=n;i++) cin >> an[i]; for(int i=1;i<=m;i++){ int tmp; cin >> tmp; am[tmp]++; } am[0]=100; an[0]=1; if(check(0,m,am)) cout << "YES"; else cout << "NO"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...