이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ii = tuple<int, int>;
using vii = vector<ii>;
using i64 = int64_t;
using vl = vector<i64>;
using ll = pair<i64, i64>;
using vll = vector<ll>;
constexpr int iINF = numeric_limits<int>::max();
constexpr i64 lINF = numeric_limits<i64>::max();
#define RANGE(x) begin(x), end(x)
template <typename... T>
void DBG(T&&... args) {
((cerr << args << ' '), ...) << '\n';
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &vec) {
out << '{';
for (size_t i = 0; i < vec.size()-1; ++i)
out << vec[i] << ", ";
out << vec.back() << '}';
return out;
}
std::vector<int> find_subset(int L, int U, std::vector<int> w) {
const int N = w.size();
vi sorted(N);
iota(RANGE(sorted), 0);
stable_sort(RANGE(sorted), [&] (auto a, auto b) {
return w[a] < w[b];
});
DBG(sorted);
vl sum(N+1);
for (int i = 1; i <= N; ++i) {
sum[i] = sum[i-1] + i64(w[sorted[i-1]]);
}
DBG(sum);
for (int l = 1; l <= N; ++l) {
for (int r = l; r <= N; ++r) {
auto rsum = sum[r] - sum[l-1];
if (rsum >= L && rsum <= U) {
DBG(l, r, rsum);
vi ans;
ans.reserve(r-l);
for (int i = l; i <= r; ++i) {
ans.push_back(sorted[i-1]);
}
DBG(ans);
return ans;
}
}
}
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... |