# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875759 | raul2008487 | Detecting Molecules (IOI16_molecules) | C++17 | 47 ms | 65536 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>
#include "molecules.h"
#define ll int
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define vl vector<ll>
using namespace std;
bool check(ll cur, ll low, ll high){
return (cur <= high && cur >= low);
}
vector<int> find_subset(int l, int u, vector<int> w) {
vl ans;
vector<pair<ll,ll>> p;
ll i, j, n = w.size(), left = 0, r = 1, sum = w[0];
for(i=0;i<n;i++){
p.pb({w[i], i});
}
sort(all(p));
bool as = 0;
while(r < n && left < r){
if(check(sum, l, u)){
for(i=left;i<=r;i++){
ans.pb(p[i-1].se);
break;
}
}
else if(sum > u){
left++;
sum -= p[left-1].fi;
}
else{
r++;
sum += p[r-1].fi;
}
}
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... |