# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
789789 | pravcoder | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 340 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 <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef long long ll;
vi find_subset(int l, int u, vi w) {
vpi m;
for (int i = 0; i < w.size(); i++)
{
m.push_back({ w[i], i });
}
sort(m.begin(), m.end());
int start = m.size() - 1;
ll sum = m[start].first;
vi set = { start };
while (sum < l) {
start--;
sum += m[start].first;
set.push_back(start);
}
int r = m.size();
int t;
while ((sum > u) && (r > m.size()/2 - 1) && (r >= start)) {
r--;
t = m.size() - r - 1;
if (t < start) {
set[t] = t;
sum -= m[r].first - m[t].first;
}
}
vi ans;
if (sum > u) return ans;
for (auto mol : set) {
ans.push_back(m[mol].second);
}
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... |