# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
288789 | Ruba_K | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 384 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 ;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
deque<int>pos (n);
iota(pos.begin() , pos.end() , 0);
sort(pos.begin() , pos.end() , [w](int a , int b){
return w[a] < w[b] ;
});
pos.push_back(0);
sort(w.begin() , w.end());
w.push_back((2 << 31) + 1);
long long sum = 0 ;
int idx = 0 ;
deque<int> ret ;
while(idx <= n && sum <= u){
sum += w[idx];
ret.push_back(pos[idx++]);
}
idx -- ;
sum -= w[idx--];
w.pop_back();
ret.pop_back();
int p1 = 0 , p2 = idx ;
while(p2 < n && !(sum >= l && sum <= u)){
ret.pop_front();
sum -= w[p1++];
sum += w[p2];
ret.push_back(pos[p2++]);
}
vector<int>ret2 ;
for(auto f : ret)
ret2.push_back(f);
if(sum >= l && sum <= u)
return ret2 ;
else return vector<int>();
}
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... |