답안 #1105886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1105886 2024-10-28T08:39:23 Z abushbandit_ Detecting Molecules (IOI16_molecules) C++17
컴파일 오류
0 ms 0 KB
#include "molecules.h"
#include "bits/stdc++.h"

using namespace std;

#define int long long

vector<int> find_subset(int a, int b, vector<int> w) {
	vector<pair<int,int>> w2;
	int j = 1;
	for(auto i : w) w2.push_back({i,j++});
	sort(w.begin(),w.end());
	sort(w2.begin(),w2.end());
	int n = w.size();
	int resr = 0,resl = n;
	int l = 0;
	int ans = 0;
	int sum = 0;
	for(int r = 0;r < n;r++) {
		sum += w[r];
		if(sum < a) {
			continue;
		}
		while(sum > b && l <= r) {
			sum -= w[l];
			l++;
		}
		if(sum >= a && sum <= b) {
			if(ans < r - l + 1) {
				ans = r - l + 1;
				resr = r,resl = l;
			}
		}
	}
	vector<int> res;
	for(int i = resl;i <= resr;i++) {
		res.push_back(w2[i].second - 1);
	}
    return res;
}

Compilation message

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