# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1018870 | AlgorithmWarrior | Detecting Molecules (IOI16_molecules) | C++14 | 29 ms | 6092 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 <cstdio>
#include <vector>
#include <cassert>
#include <algorithm>
#include "molecules.h"
using namespace std;
struct str
{
int val;
int ind;
};
bool crt(str a,str b)
{
return a.val<b.val;
}
vector<int> find_subset(int l, int u, vector<int> w) {
vector<str>date(w.size());
int i;
for(i=0;i<date.size();++i)
date[i]={w[i],i};
sort(date.begin(),date.end(),crt);
vector<int>res;
int total=0;
for(i=date.size()-1;i>=0;--i)
{
total+=date[i].val;
res.push_back(date[i].ind);
if(l<=total && total<=u)
return res;
if(total>u)
break;
}
if(i==-1)
return vector<int>(0);
int care;
for(care=0;i<date.size();++i,++care)
{
total-=date[i].val;
total+=date[care].val;
res[res.size()-1-care]=date[care].ind;
if(l<=total && total<=u)
return res;
}
return vector<int>(0);
}
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... |