Submission #289638

# Submission time Handle Problem Language Result Execution time Memory
289638 2020-09-02T20:49:16 Z peti1234 Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
long long sum, n, kezd=-1, veg;
vector<pair<long long, int> >sz;
vector<int> ans;
void add(int a, int b) {
    sum+=b*sz[a].first;
}
vector<int> find_subset(long long a, long long b, vector<int> w) {
    n=w.size(), veg=n;
    for (int i=0; i<n; i++) {
        sz.push_back({w[i], i});
    }
    sort(sz.rbegin(), sz.rend());
    while(kezd+1<n && sum<a) {
        kezd++;
        add(kezd, 1);
    }
    if (kezd<=sum && sum<=veg) {
        for (int i=0; i<=kezd; i++) ans.push_back(sz[i].second);
        return ans;
    }
    while(kezd>=0 && sum>b) {
        add(kezd, -1), kezd--;
        veg--, add(veg, 1);
        if (sum<=b) {
            for (int i=0; i<=kezd; i++) ans.push_back(sz[i].second);
            for (int i=veg; i<n; i++) ans.push_back(sz[i].second);
            return ans;
        }
    }
    return ans;
}

Compilation message

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