# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
616231 | jairRS | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 300 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;
using vi = vector<int>;
using pii = pair<long long, long long>;
#ifndef LOCALDEBUG
#define LOCALDEBUG false
#endif
vi find_subset(int l, int u, vi w) {
vector<pii> molecules;
for (int i = 0; i < w.size(); i++)
molecules.push_back({w[i], i});
molecules.push_back({1e18, -1});
sort(molecules.begin(), molecules.end());
long long curSum = 0;
for (int i = 0; i < molecules.size(); i++)
{
pii cur = molecules[i];
curSum += cur.first;
if(curSum > u){
//find w_p
int p = -1;
for (int j = 0; j <= i; j++)
{
long long newSum = curSum - molecules[j].first;
if(l <= newSum && newSum <= u){
p = j;
break;
}
}
if(p == -1)
return vi();
vi ans;
for (int k = 0; k <= i; k++)
{
if(k == p)
continue;
ans.push_back(molecules[k].second);
}
return ans;
}
}
return vi();
}
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... |