# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
254462 | babo | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define L long long
using namespace std;
int n;
L s,e;
struct S{
L idx, weight;
};
bool operator<(S a,S b){
return a.weight<b.weight;
}
vector<int> solve(int l,int u, vector<int> w){
n=w.size();
vector<int> ans(n);
L i;
s=l,e=u;
L W=0;
vector<S>v;
for(i=0;i<n;i++)
v.push_back((S){i,w[i]});
sort(v.begin(),v.end());
for(i=n-1;i>=0;i--)
{
W+=v[i].weight;
ans[v[i].idx]=1;
if(W>e)
{
L j=n-1;
while(i>0)
{
W+=v[i-1].weight;
ans[v[i-1].idx]=1;
W-=v[j].weight;
ans[v[j].idx]=0;
i--;j--;
if(s<=W&&W<=e) return ans;
}
break;
}
else if(W>=s)
return ans;
}
vector<int> ans2(n,0);
return ans2;
}