# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
57832 | robert | Detecting Molecules (IOI16_molecules) | C++14 | 106 ms | 31836 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 <iostream>
#include <vector>
#include <algorithm>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> wt){
vector<pair<int, int> > w;
for(int z=0; z<wt.size(); z++)
w.push_back({wt[z], z});
sort(w.begin(), w.end());
vector<int> res;
long long sum = 0;
int x = 0;
for(; x<w.size(); x++){
sum += w[x].first;
if(sum>=l)
break;
}
// cout << sum << endl;
if(sum<l)
return res;
if(sum<=u){
//solution 0...x
for(int z=0; z<=x; z++){
res.push_back(w[z].second);
}
return res;
}
int y = 0; sum -= w[x].first;
while(x<w.size()){
if(sum>=l&&sum<=u)
break;
sum -= w[y++].first;
sum += w[x++].first;
if(sum>=l&&sum<=u)
break;
}
if(sum<l)
return res;
for(int z=y; z<x; z++){
res.push_back(w[z].second);
}
return res;
}
/*
int main(){
vector<int> r = {15, 17, 16, 18};
vector<int> a = find_subset(10, 20, r);
for(int x=0; x<a.size(); x++)
cout << a[x] << endl;
}*/
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... |