Submission #854820

#TimeUsernameProblemLanguageResultExecution timeMemory
854820hungt58Bank (IZhO14_bank)C++14
0 / 100
2 ms500 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define ll long long #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 (b[i]<=a[j]) { a[j]-=b[i]; if (a[j]==0) res--; if (m-i>=res) { if (i==m) {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; n++; a[n]=100000; for (ll i=1;i<=n;i++) cin>>a[i]; for (ll i=1;i<=m;i++) cin>>b[i]; res=n; 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...