# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
789790 | pravcoder | Detecting Molecules (IOI16_molecules) | C++17 | 3 ms | 980 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() - 1;
int t = 0;
while ((sum > u) && (t < start) && (r >= start)) {
set[t] = t;
sum -= m[r].first - m[t].first;
r--;
t++;
}
if (sum > u) return vi(0);
vi 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... |