제출 #1027644

#제출 시각아이디문제언어결과실행 시간메모리
1027644vjudge1은행 (IZhO14_bank)C++14
19 / 100
1063 ms348 KiB
#include <bits/stdc++.h> using namespace std; int n,m; const int MAX=20; int plata[MAX],pari[MAX]; bool flag=false; void f(int i,int cnt[]) { if(i>=m) { for(int j=0; j<n; j++)if(plata[j]!=cnt[j])return; flag=true; return; } for(int j=0; j<n; j++) { if(cnt[j]+pari[i]<=plata[j]) { cnt[j]+=pari[i]; f(i+1,cnt); cnt[j]-=pari[i]; } //cout<<"add: "<<pari[i]<<" on pos: "<<j+1<<endl; f(i+1,cnt); } } int main() { cin>>n>>m; for(int i=0; i<n; i++)cin>>plata[i]; sort(plata,plata+n); for(int i=0; i<m; i++)cin>>pari[i]; int cnt[n]; memset(cnt,0,sizeof(cnt)); f(0,cnt); if(flag)cout<<"YES"<<endl; else cout<<"NO"<<endl; 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...