# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289432 | Basilhijaz | Detecting Molecules (IOI16_molecules) | C++17 | 65 ms | 4724 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>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<pair<int, int> > vec;
vector<int> ans;
long long aa = 0;
for(int i = 0; i < w.size(); i++){
vec.push_back({w[i], i});
aa += w[i];
if(w[i] >= l && w[i] <= u){
ans.push_back(i);
return ans;
}
}
sort(vec.begin(), vec.end());
long long sum = vec[0].first;
int p1 = 0, p2 = 0;
if(vec[0].first > u || aa < l)return ans;
while(p1 <= p2){
if(sum >= l && sum <= u)break;
if(sum > u){
sum -= vec[p1].first;
p1++;
}
else{
p2++;
if(p2 == vec.size())break;
sum += vec[p2].first;
}
}
if(sum < l || sum > u)return ans;
for(int i = p1; i <= p2; i++){
ans.push_back(vec[i].second);
}
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... |