# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1257031 | luyendhqn | Detecting Molecules (IOI16_molecules) | C++20 | 38 ms | 6828 KiB |
//dan4life
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
using ll = long long;
const int mxN = (int)2e5+10;
vector<pair<ll,int>> v;
ll pre[mxN];
vector<int> find_subset(int L, int R, vector<int> w) {
v.clear(); int n = (int)w.size();
for(int i = 0; i < n; i++) v.push_back({w[i],i});
sort(all(v)); pre[0]=0;
for(int i = 0; i < n; i++)
pre[i+1] = pre[i]+v[i].first;
vector<int> ans; ans.clear();
for(int i = 0, j = 0; i < n; i++){
while(j<=n and pre[j]-pre[i] < L) j++;
if(j==n+1) break;
ll sum = pre[j]-pre[i];
if(L<=sum and sum<=R){
for(int k = i; k < j; k++)
ans.push_back(v[k].second);
return ans;
}
}
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... |