# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1026052 | 0npata | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 436 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vec vector
std::vector<int32_t> find_subset(int32_t l, int32_t u, std::vector<int32_t> w) {
int n = w.size();
vec<int> wi(n);
iota(wi.begin(), wi.end(), 0);
sort(wi.begin(), wi.end(), [&](int i, int j) { return w[i] < w[j]; });
sort(w.begin(), w.end());
int k = 0;
int sum = 0;
while(k < w.size() && sum + w[k] <= u) {
sum += w[k];
k++;
}
if(k == w.size()) return {};
int j = 0;
while(j+k < n && sum < l) {
sum += w[j+k];
sum -= w[j];
j++;
}
if(sum < l) return {};
vec<int32_t> ans(0);
for(int i = j; i < j+k; i++) {
ans.push_back(wi[i]);
}
return ans;
}
Compilation message (stderr)
# | 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... |