# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209098 | my99n | Detecting Molecules (IOI16_molecules) | C++14 | 5 ms | 376 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<bits/stdc++.h>
using namespace std;
#include "molecules.h"
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> ans;
vector<pair<int,int>> s;
for (int i = 0; i < w.size(); i++) s.push_back({w[i], i});
sort(s.begin(), s.end());
int wmax = (s.end()-1)->first, wmin = s.begin()->first;
if (wmin > u) return vector<int>(0);
if (l <= wmin and u >= wmin) return vector<int>(1, s[0].second);
if (l <= wmax and u >= wmax) return vector<int>(1, s.back().second);
reverse(s.begin(), s.end());
int val = 0;
for (int i = 0; i < s.size(); i++) {
ans.push_back(s.size()-s[i].second-1);
val += s[i].first;
if (val < l) continue;
if (l <= val and val <= u) return ans;
if (u < val) {
ans.pop_back();
val -= w[i];
continue;
}
}
return vector<int>(0);
}
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... |