# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833627 | BilAktauAlmansur | Bank (IZhO14_bank) | C++17 | 2 ms | 340 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>
// #pragma optimize ("g",on)
// #pragma GCC optimize ("inline")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC optimize ("03")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
// #pragma comment(linker, "/stack:200000000")
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
// #define int long long
using namespace std;
int n, m;
int a[27], b[27];
signed main() {
file("bank");
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cin>>n>>m;
for(int i = 1; i <= n; i++)cin>>a[i];
for(int i = 1; i <= m; i++)cin>>b[i];
sort(b + 1, b + 1 + m);
bool ok = 0;
do {
int cnt = 0;
int i = 1;
bool f = 1;
for(int j = 1; j <= m; j++) {
if(cnt + b[j] == a[i]) {
i++;
if(i == n + 1)break;
cnt = 0;
}else if(cnt + b[j] > a[i]) {
f = 0;
break;
}else cnt += b[j];
}
if(f)ok = 1;
}while(next_permutation(b + 1, b + 1 + m));
cout << (ok ? "YES\n" : "NO\n");
}
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... |