답안 #1077635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077635 2024-08-27T08:28:02 Z speedcode Detecting Molecules (IOI16_molecules) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int find_subset(int l, int u, int* w, int n, int* result){
    vector<pair<int, int>> dat(n);
    for(int i = 0; i < n; i++){
        dat[i] = {w[i], i};
    }
    sort(dat.begin(), dat.end());
    ll s1 = dat[0].first;
    ll s2 = dat[n-1].first;
    int k = 1;
    while(k <= n){
        if(s1 > u || s2 < l){
            k++;
            s1 += dat[k-1].first;
            s2 += dat[n-k].first;
        }else{
            int ind = 0;
            for(int i = 0; i < k; i++){
                result[i] = dat[i].second;
            }
            while(s1 < u){
                s1 -= dat[ind].first;
                s1 += dat[n-ind-1].first;
                result[ind] = dat[n-ind-1].second;
            }
            return k;
        }
    }

    return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccmwllhE.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