답안 #255822

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255822 2020-08-01T22:40:49 Z jainbot27 Detecting Molecules (IOI16_molecules) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
// #include <molecules.h>
using namespace std;
using ll = long long; 
// u - l >= wmax - wmin
// what does this mean for me
vector<int> find_subset(int l, int u, vector<int> w){
	vector<int> ret;
	vector<pair<int, int>> ww;
	int n = w.size();
	for(int i =0; i < n; i++){
		ww.push_back({w[i], i});
	}	
	sort(ww.begin(), ww.end());
	if(ww[0].first >= l && ww[0].first<= u){
		ret.push_back(ww[0].second);
		return ret;
	}
	int z = 0;
	ll sum = ww[0].first;
	for(int i =1; i < n; i++){
		sum += ww[i].first;
		while(sum > u && z < n){
			sum -= ww[z].first;
			z++;
		}
		if(sum >= l && sum <= u){
			for(int j = z; j <= i; j++){
				ret.push_back(ww[j].second);
			}
			return ret;
		}
	}
	return ret;
}

int main(){
	int l = 15;
	int u = 20;
	vector<int> w = {7, 8, 12, 12}; 
	vector<int> ret = find_subset(l, u, w);
	for(int x : ret){
		cout << x << " ";
	}
	cout << endl;
}

Compilation message

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