이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
int L,U,n,a[200010],id[200020],pre[200010],su[200010];
bool cmp(int x, int y){
return a[x]<a[y];
}
vector<int> find_subset(int l, int u, vector<int> w) {
n=w.size();
for(int i=0; i<n; i++){
a[i]=w[i];
id[i]=i;
}
sort(id, id+n, cmp);
//for(int i=0; i<n; i++)cout<<id[i]<<" ";
// cout<<endl;
for(int i=1; i<=n; i++){
pre[i]=pre[i-1]+a[id[i-1]];
}
for(int i=n; i>=1; i--){
su[i]=su[i+1]+a[id[i-1]];
}
//for(int i=1; i<=n; i++) cout<<su[i]<<" ";
// cout<<endl;
int low=0, high=n+1;
while(high - low >= 2){
int mid = (high + low) / 2;
if(pre[mid]>l) high = mid;
else low = mid;
}
//printf("%d, %d \n",high, low);
high=low;
for(int i=0; i<high; i++){
//cout<<pre[i]+su[n-high+i+1]<<" "<<(pre[i]+su[n-high+i+1]>=l)<<" "<<(pre[i]+su[n-high+i+1]<=u)<<endl;
if(pre[i]+su[n-high+i+1]>=l&&pre[i]+su[n-high+i+1]<=u){
vector<int> v;
for(int j=1; j<=i; j++){
v.push_back(id[j]);
}
for(int j=n-high+i+1; j<=n; j++){
v.push_back(id[j]);
}
return v;
}
}
return vector<int>(0);
}
# | 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... |