Submission #209865

# Submission time Handle Problem Language Result Execution time Memory
209865 2020-03-15T18:34:57 Z thebes Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int MN = 2e5+5;
pair<int,int> arr[MN];
long long psa[MN];
int find_subset(int l,int u,int *w,int n,int *res){
	int mn = w[0];
	for(int i=0;i<n;i++)
		mn = min(w[i], mn);
	for(int i=0;i<n;i++)
		arr[i]={w[i]-mn,i};
	int ans = 0;
	sort(arr,arr+n,[](pair<int,int>i,pair<int,int>j){return i.first<j.first;});
	for(int i=0;i<n;i++) psa[i+1]=psa[i]+arr[i].first;
	for(int i=1;i<=n;i++){
		long long a=psa[i], b=psa[n]-psa[n-i];
		if(a+1LL*i*mn<=1LL*u&&b+1LL*i*mn>=1LL*l){
			ans = i;
			for(int i=ans;i<=n;i++){
				long long tmp = psa[i]-psa[i-ans]+1LL*mn*ans;
				if(tmp>=l&&tmp<=u){
					for(int j=i-ans;j<i;j++)
						res[j-i+ans]=arr[j].second;
					return ans;
				}
			}
		}
	}
	return 0;
}

Compilation message

/tmp/ccfdzynv.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