이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using i64 = long long;
int z=4, n, m, a[21], b[20], dp[2][1<<20];
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")
int main()
{
ShinLena;
cin >> n >> m;
memset(dp, 0x86, sizeof dp);
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 0; i < m; ++i) cin >> b[i];
dp[0][0] = 0;
for (int i = 0, I = 0; z && i <= n; ++i, I^=1)
{
if (i) memset(dp[I], 0x86, sizeof *dp);
for (int j = 0; z && j < (1 << m); ++j)
{
if (i)
if (dp[!I][j] == a[i]) dp[I][j] = 0;
for (int k = 0; k < m; ++k)
{
if (j & (1 << k))
{
int p = j&~(1<<k);
dp[I][j] = max(dp[I][j], dp[I][p] + b[k]);
}
}
if (i == n && !dp[I][j]) z = 0;
}
}
cout << &"YES\0NO"[z];
return 0;
}
| # | 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... |