# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
800309 | LIF | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 308 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>
//some tricks :
//if we want to check if the sum of set can reach : [l,r], we can find it maxn, it minn ,
//sometimes it will useful , but sometimes not.
//in this cases : it is useful since the max element of the set subtract the min element of the set is less than r-l, so it will not skip the range.
using namespace std;
pair<long long int,int> a[300005];
long long int suf[300005];
long long int pre[300005];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
for(int i=0;i<w.size();i++)
{
a[i+1].first = w[i];
a[i+1].second = i+1;
}
sort(a+1,a+w.size()+1);
int n = w.size();
for(int i=1;i<=n;i++)pre[i] = pre[i-1] + a[i].first;
for(int i=n;i>=1;i--)suf[i] = suf[i+1] + a[i].first;
bool flag = false;
int k = 0;
for(int i=1;i<=n;i++)
{
if(pre[i] <= u && suf[i] >= l)
{
k = i;
flag = true;
}
}
vector<int> ans;
if(flag == false)return ans;
for(int i=k;i<=n;i++)
{
if(pre[i] - pre[i-k] >= l && pre[i] - pre[i-k] <= u)
{
for(int j=i-k+1;j<=i;j++)ans.push_back(a[j].second);
break;
}
}
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... |