# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
603851 | strange420 | Detecting Molecules (IOI16_molecules) | C++14 | 58 ms | 6172 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;
typedef pair<int, int> ii;
bool func(const ii& a, const ii& b) { return a.first < b.first; }
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<ii> asd;
for (int i=0; i<w.size(); i++)
asd.push_back(ii(w[i], i));
sort(asd.begin(), asd.end(), func);
vector<int> ans;
int leftPt = 0, rightPt = 1;
long long sum = asd[0].first;
while(true) {
if (sum > u) {
sum -= asd[leftPt].first;
leftPt++;
if (leftPt > rightPt) break;
} else if (sum < l) {
if (rightPt == asd.size()) break;
sum += asd[rightPt].first;
rightPt++;
} else if (l <= sum && sum <=u) {
for (int i=leftPt; i<rightPt; i++)
ans.push_back(asd[i].second);
break;
}
}
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... |