이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
vector<pair<ll,int>> v;
ll pre[mxN];
vector<int> find_subset(int L, int R, vector<int> w) {
v.clear(); int n = sz(w);
for(int i = 0; i < n; i++) v.pb({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; i < n; i++){
int l = i+1, r = n;
while(l<min(r,n+1)){
int mid = (l+r)/2;
ll sum = pre[mid]-pre[i];
if(sum<L) l=mid+1;
else r=mid;
}
if(l==n+1) continue;
ll sum = pre[l]-pre[i];
if(L<=sum and sum<=R){
for(int j = i; j < l; j++)
ans.pb(v[j].second);
return ans;
}
}
return ans;
}
# | 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... |