# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
288808 | Ruba_K | Detecting Molecules (IOI16_molecules) | C++14 | 1088 ms | 12932 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());
if(w[0] > u)return {};
w.push_back((2 << 31) + 1);
long long sum = 0 ;
int idx = 0 ;
deque<pair<int , int > > ret ;
for(int i = 0 ; i < n ; i ++){
ret.push_back({w[i] , pos[i]});
sum += w[i];
while(sum > u){
sum -= ret.front().first ;
ret.pop_front();
}
if(sum >= l && sum <= u){
vector<int>ans ;
for(auto f : ret)
ans.push_back(f.second);
sort(ans.begin() , ans.end());
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... |