Submission #305566

# Submission time Handle Problem Language Result Execution time Memory
305566 2020-09-23T14:41:50 Z tengiz05 Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include "molecules.h"
#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
	int n = w.size();
	vector<pair<int, int>> a;
	for(int i=0;i<n;i++){
		a.push_back({w[i], i});
	}
	sort(a.begin(), a.end());
	vector<int> ans;
	
	int sum = 0;
	for(auto x : w)sum += x;
	if(sum < l)return ans;
	
	sum = 0;
	int m=0;
	for(int i=0;i<n;i++){
		sum += a[i].first;
		while(sum > u)sum -= a[m].first, m++;
		
		if(sum >= l && sum <= u){
			for(int j=m;j<=i;j++)ans.push_back(a[j].second);
			break;
		}
	}
//	cout << sum << ' ';
    return ans;
}

/*

4 15 17
6 8 8 7

4 14 15
5 5 6 6

4 10 20
15 17 16 18

*/

Compilation message

/tmp/ccN4W6FR.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cccQEUKk.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status