# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1106437 | SonicML | Detecting Molecules (IOI16_molecules) | C++14 | 42 ms | 5712 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 <vector>
#include <algorithm>
#include "molecules.h"
using namespace std;
int const NMAX = 2e5;
int arr[1 + NMAX];
int ind[1 + NMAX];
bool compareIndex(int a, int b) {
return (arr[a] < arr[b]);
}
vector <int> find_subset(int l, int u, vector<int> w) {
vector <int> result;
int n = w.size();
for(int i = 0;i < w.size();i++) {
ind[i] = i;
arr[i] = w[i];
}
sort(ind, ind+n, compareIndex);
int from = 0;
long long sum = 0;
bool foundSol = false;
for(int to = 0;to < n && !foundSol;to++) {
sum += arr[ind[to]];
while(sum > u) {
sum -= arr[ind[from]];
from++;
}
if(l <= sum && sum <= u) {
foundSol = true;
for(int i = from;i <= to;i++) {
result.push_back(ind[i]);
}
}
}
return result;
}
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... |