제출 #854829

#제출 시각아이디문제언어결과실행 시간메모리
854829hungt58은행 (IZhO14_bank)C++14
71 / 100
1091 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define ll int #define TIME (1.0 * clock() / CLOCKS_PER_SEC) typedef pair<ll,ll> ii; const ll maxn=300010; ll n,m,a[22],b[22],kt[22],res=0; void dao(ll i) { for (ll j=1;j<=n;j++) if (a[j]>=b[i]) { a[j]-=b[i]; if (a[j]==0) res--; if (m-i>=res) { if (i==m) {if (res==0){cout<<"YES";exit(0);}} else dao(i+1); } if (a[j]==0) res++; a[j]+=b[i]; } } int main() { ios_base :: sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>n>>m; for (ll i=1;i<=n;i++) cin>>a[i]; n++; a[n]=100010; for (ll i=1;i<=m;i++) cin>>b[i]; res=n-1; dao(1); cout<<"NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...