# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132452 | bogdan10bos | Detecting Molecules (IOI16_molecules) | C++14 | 3 ms | 424 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.
/// inapt
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<int> find_subset(int l, int u, vector<int> w)
{
vector<int> ord;
for(int i = 0; i < w.size(); i++) ord.push_back(i);
sort(ord.begin(), ord.end(),
[&](int a, int b) { return w[a] < w[b]; } );
vector<LL> sum(w.size());
LL s = 0;
for(int i = 0; i < w.size(); i++)
{
s += w[ ord[i] ];
sum[i] = s;
}
vector<int> ans;
if(l <= s && s <= u)
{
sort(ord.begin(), ord.end());
return ord;
}
int L = l, R = u, N = w.size();
for(int i = 0; i < w.size(); i++)
{
if(sum[i] > R) break;
if(s - sum[N - i - 2] < L) continue;
int lgt = i + 1;
for(int j = 0; j + lgt < N; j++)
{
LL ss = sum[j + lgt - 1];
if(j > 0) ss -= sum[j - 1];
if(L <= ss && ss <= R)
{
for(int k = j; k < j + lgt; k++) ans.push_back(ord[k]);
sort(ans.begin(), ans.end());
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... |