# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90910 | RAkhshon | Bank (IZhO14_bank) | C++14 | 1087 ms | 644 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define st string
#define fr first
#define se second
#define INF 1000000000
using namespace std;
ll a[101101], b[101101], dp[101101];
int main()
{
ll n, m;
scanf("%lld %lld", &n, &m);
ll s;
for(ll i = 1; i <= n; i ++){
scanf("%lld", &a[i]);
}
for(ll i = 1; i <= m; i ++){
scanf("%lld", &b[i]);
}
sort(a+1,a+1+n);
sort(b+1,b+1+m);
do{
ll sum = 0, num = 1;
for(ll i = 1; i <= m; i ++){
sum=sum+b[i];
if(num == n + 1) break;
if(sum > a[num]) break;
if(sum == a[num]) sum=0,num++;
}
if(num == n+1){
printf("YES");
return 0;
}
}while(next_permutation(b+1,b+1+m));
printf("NO");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |