답안 #254462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
254462 2020-07-30T04:20:47 Z babo Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#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;
}

Compilation message

/tmp/ccQgQnrl.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status