이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
#define ffor(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define fford(i, a, b) for (ll i = (a); i > (ll)(b); i--)
#define rep(i, n) ffor(i, 0, n)
#define forin(x, a) for (auto &x: a)
#define all(a) a.begin(), a.end()
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
map<int, int> cnts;
forin(weight, w) {
cnts[weight]++;
}
map<int, pii> reached = {{0, {-1, -1}}};
forin(cnt, cnts) {
map<int, pii> nreached(reached);
forin(val, reached) {
ffor(i, 1, cnt.second + 1) {
if (val.first + cnt.first * i > u) {
break;
}
nreached[val.first + cnt.first * i] = {cnt.first, i};
if (val.first + cnt.first * i >= l) {
map<int, int> needed;
int curr = val.first + cnt.first * i;
while(curr) {
needed[nreached[curr].first] = nreached[curr].second;
curr -= nreached[curr].first * nreached[curr].second;
}
vii res;
rep(j, w.size()) {
if (needed[w[j]]) {
res.emplace_back(j);
needed[w[j]]--;
}
}
return res;
}
}
}
reached = move(nreached);
}
return {};
}
# | 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... |