# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1015609 | Unforgettablepl | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 436 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>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<pair<int,int>> arr;
for(int i=0;i<w.size();i++)arr.emplace_back(w[i],i);
sort(arr.begin(),arr.end());
int n = arr.size();
int totsum = 0;
for(auto[a,b]:arr)totsum+=a;
map<int,int> lookup;
lookup[0]=n;
int currsum = totsum;
for(int i=n-1;i>=0;i--){
auto it1 = lookup.lower_bound(l-currsum);
auto it2 = lookup.upper_bound(u-currsum);
currsum-=arr[i].first;
lookup[totsum-currsum]=i;
if(it1==it2)continue;
int ix = it1->second;
vector<int> ans;
for(int j=0;j<=i;j++)ans.emplace_back(arr[j].second);
for(int j=ix;j<n;j++)ans.emplace_back(arr[j].second);
return ans;
}
return {};
}
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... |