이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) //x
#define A(x) DEBUG(assert(x))
#define PRINT(x) DEBUG(cerr << x)
#define PV(x) DEBUG(cerr << #x << " = " << x << '\n')
#define PV2(x) DEBUG(cerr << #x << " = " << x.first << ',' << x.second << '\n')
#define PAR(x) DEBUG(PRINT(#x << " = { "); for (auto y : x) PRINT(y << ' '); PRINT("}\n");)
#define PAR2(x) DEBUG(PRINT(#x << " = { "); for (auto [y, z] : x) PRINT(y << ',' << z << " "); PRINT("}\n");)
typedef int64_t i64;
const int INF = 1000000007; //998244353;
struct S {
int n, m;
vector<int> a, b;
void run() {
cin >> n >> m;
a.resize(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
b.resize(m);
for (int i = 0; i < m; ++i) {
cin >> b[i];
}
vector<int> last(1 << m, 0), left(1 << m, 0);
for (int i = 0; i < 1 << m; ++i) {
int option = 0;
for (int j = 0; j < m; ++j) {
if (!(i & (1 << j))) continue;
int prev = i ^ (1 << j);
if (left[prev] + b[j] == a[last[prev]] && last[prev] + 1 >= last[i]) {
last[i] = last[prev] + 1;
left[i] = 0;
option = 2;
} else if (left[prev] + b[j] < a[last[prev]] && last[prev] >= last[i]) {
last[i] = last[prev];
left[i] = left[prev] + b[j];
option = 1;
}
}
if (last[i] == n) {
cout << "YES\n";
return;
}
}
cout << "NO\n";
}
};
int main() {
ios::sync_with_stdio(0); cin.tie(0);
auto sol = make_unique<S>();
sol->run();
}
컴파일 시 표준 에러 (stderr) 메시지
bank.cpp: In member function 'void S::run()':
bank.cpp:30:11: warning: variable 'option' set but not used [-Wunused-but-set-variable]
30 | int option = 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... |