# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138328 | arthurconmy | Detecting Molecules (IOI16_molecules) | C++14 | 3 ms | 376 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 <bits/stdc++.h>
#ifndef ARTHUR_LOCAL
#include "molecules.h"
#endif
using namespace std;
vector<int> find_subset(int l, int r, vector<int> W_raw)
{
int n = W_raw.size();
vector<pair<int,int>> W;
for(int i=0; i<W_raw.size(); i++)
{
W.push_back(make_pair(W_raw[i],i));
}
sort(W.begin(),W.end());
int cur1=0;
int cur2=0;
vector<int> v1;
vector<int> v2;
bool works=0;
for(int i=1; i<=n; i++)
{
cur1 += W[i-1].first;
v1.push_back(i-1);
cur2 += W[n-i].first;
v2.push_back(n-i);
if(cur1 >= l && cur1 <= r)
{
// return cur1 things
return v1;
}
if(cur2 >= l && cur2 <= r)
{
return v2;
}
if(cur1 < l && cur2 > r)
{
works=1;
break;
}
}
if(!works) return {};
for(int i=0; i<v1.size(); i++)
{
cur2 -= W_raw[v2[i]];
cur2 += W_raw[v1[v1.size()-i-1]];
v2[i]=v1[v1.size()-i-1];
if(cur2 <= r) return v2;
}
}
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... |