# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
754689 | alexander707070 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute i
*/
#include <bits/stdc++.h>
using namespace std;
int n,pref[200007];
pair<int,int> a[200007];
vector<int> answer(int l,int r){
vector<int> res;
for(int i=l;i<=r;i++){
res.push_back(a[i].second);
}
return res;
}
vector<int> find_subset(int l,int u,vector<int> w){
n=w.size();
for(int i=1;i<=n;i++){
a[i]={w[i-1],i-1};
}
sort(a+1,a+n+1);
for(int i=1;i<=n;i++){
pref[i]=pref[i-1]+a[i].first;
}
for(int i=1;i<=n;i++){
int ll=0,int rr=i;
while(ll+1<rr){
mid=(ll+rr)/2;
if(pref[i]-pref[mid]>=l){
ll=mid;
}else{
rr=mid;
}
}
if(pref[i]-pref[ll-1]>=l and pref[i]-pref[ll-1]<=u){
return answer(ll,i);
}
}
}
return {};
}