# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
744352 | Dan4Life | Detecting Molecules (IOI16_molecules) | C++17 | 52 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 "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
using ll = long long;
const int mxN = (int)2e5+10;
ll pre[mxN];
/*
4 15 17
6 8 8 7
*/
vector<int> find_subset(int L, int R, vector<int> w) {
vector<pair<int,int>> v; v.clear();
for(int i = 1; auto u : w) v.pb({u,i++});
sort(all(v)); int n = sz(v); pre[0]=0;
for(int i = 0; i < n; i++)
pre[i+1] = pre[i]+(ll)v[i].first;
vector<int> ans; ans.clear();
for(int i = 0; i < n; i++){
int l = i+1, r = n;
if(pre[r]-pre[i]<L) continue;
L+=pre[i], R+=pre[i];
while(l<r){
int mid = (l+r)/2;
if(pre[mid]<L) l=mid+1;
else r=mid;
}
if(L<=pre[l] and pre[l]<=R){
for(int j = i; j < l; i++) ans.pb(v[j].second);
return ans;
}
L-=pre[i], R-=pre[i];
}
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... |