| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 737236 | mariaclara | Bank (IZhO14_bank) | C++17 | 1067 ms | 212 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>
using namespace std;
const int MAXN = (1<<20)+10;
#define pb push_back
int n, m, salary[25], note[25];
bool dp[MAXN];
bool solve(int i, int mask) {
// Marca se da pra formar os valores de 1 a i
if(i>n) return 1;
if(dp[mask]) return 0;
dp[mask] = 1;
for(int l=1, r=m; l<=r; ) {
if(mask&(l-1)) l++;
if(mask&(r-1)) r--;
if(note[l]+note[r]<salary[i]) l++;
else if(note[l]+note[r]>salary[i]) r--;
else if(solve(i+1, mask+(1<<l-1)+(1<<r-1))) return 1;
}
return 0;
}
int main() {
cin >> n >> m;
for(int i = 1; i <= n; i++)
cin >> salary[i];
for(int i = 1; i <= m; i++)
cin >> note[i];
sort(note+1, note+1+m);
if(solve(1,0)) cout << "YES\n";
else cout << "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... | ||||
