이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast,unroll-loops,trapv")
#pragma GCC target ("tune=native,avx2")
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
#define f first
#define s second
#define mkpr make_pair
#define pque priority_queue
#define pb push_back
#define pf push_front
#define vec vector
#define pf push_front
#define Yes cout << "Yes\n";
#define YES cout << "YES\n";
#define No cout << "No\n";
#define NO cout << "NO\n";
#define em(x) (bool)(x).empty()
#define all(x) (x).begin(), (x).end()
#define tc int tc;cin >> tc; while(tc--)
#define cps CLOCKS_PER_SEC
const int N = 1e5 + 5, P = 1e9 + 7;
int n, m, x, pr[N], a[N], b[N], dp[(1 << 20)];
int main() {
ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
pr[i] = pr[i - 1] + a[i];
}
pr[n + 1] = P;
for (int i = 0; i < m; i++)
cin >> b[i];
for (int i = 0; i < (1 << m); i++) {
x = 0;
for (int j = 0; j < m; j++)
if ((i >> j) & 1)
dp[i] = max(dp[i], dp[i ^ (1 << j)]), x += b[j];
if (pr[dp[i] + 1] == x)
dp[i]++;
}
if (dp[(1 << m) - 1] == n)
YES
else
NO
}
# | 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... |