# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
849735 | chilengaming | Detecting Molecules (IOI16_molecules) | C++17 | 1035 ms | 600 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>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> ans;
vector<pair<int, int>> ww;
int i = 0;
for(int &a : w) {
ww.push_back({a, i});
i++;
}
sort(ww.begin(), ww.end());
while(ww.size() && ww.back().first > u) ww.pop_back();
if(!ww.size()) return ans;
int L = 0, R = 0;
long long sum = ww[0].first;
if(sum >= l && sum <= u) {
for(int j = L; j <= R; j++) {
ans.push_back(ww[j].second);
}
return ans;
}
while(L != ww.size() - 1 || R != ww.size() - 1) {
while(sum < l && R + 1 < ww.size()) {
R++;
sum += ww[R].first;
}
if(sum >= l && sum <= u) {
for(int j = L; j <= R; j++) {
ans.push_back(ww[j].second);
}
return ans;
}
while(sum > u) {
sum -= ww[L].first;
L++;
}
if(sum >= l) {
for(int j = L; j <= R; j++) {
ans.push_back(ww[j].second);
}
return ans;
}
}
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... |