#include "molecules.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define ALL(x) (x.begin()), (x.end())
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DEBUG_ARR(x) cerr << #x << ": "; for (auto &y : x) cout << y << " "; cout << endl;
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
sort(ALL(w));
int n = SZ(w);
vector<pii> dp(u+1, {-1, 0}); // {prev, added}
dp[0] = {0, 0};
int ok = 0;
for (int i = 0; i < n; i++) {
for (int pw = 0; pw < u; pw++) {
int nw = w[i]+pw;
if (nw > u || dp[pw].fi == -1) continue;
dp[nw] = {pw, i+1};
if (nw >= l && nw <= u) {
ok = nw;
break;
}
}
if (ok) break;
}
vi ans;
if (!ok) return ans;
ans.reserve(n);
while (ok) {
ans.push_back(dp[ok].se);
ok = dp[ok].fi;
}
return ans;
}
// n^2 dp -> 31pts
컴파일 시 표준 에러 (stderr) 메시지
molecules.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |