Submission #636094

#TimeUsernameProblemLanguageResultExecution timeMemory
636094nehasaneDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
// #include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    
    vector <int> ans;
    int n = w.size(), p = 0;
    vector <pair <int, int>> wt(n);
    for (int i = 0; i < n; i++)
        wt[i] = {w[i], i};
    sort(wt.begin(), wt.end());
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        if (sum + wt[i].first >= l) {
            p = i;
            break;
        }
        sum += wt[i].first;
        ans.push_back(wt[i].second);
    }
    for (int i = p; i < n; i++) {
        if (sum + wt[i].first >= l && sum + wt[i].first <= u) {
            ans.push_back(wt[i].second);
            sum += wt[i].first;
            break;
        }
    }
    if (sum < l)
        ans.clear();
    return ans;
}
int main() {
    int n, l, u;
    cin >> n >> l >> u;
    vector <int> w(n);
    for (int i = 0; i < n; i++)
        cin >> w[i];
    vector <int> ans = find_subset(l, u, w);
    for (auto i : ans)
        cout << i << ' ';
    cout << '\n';
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccPhRGTs.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccIsYkKr.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status