Submission #1169650

#TimeUsernameProblemLanguageResultExecution timeMemory
1169650nathlol2Detecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include "molecules.h"
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    int n = w.size();
    vector<pair<int, int>> g(n);
    for(int i = 0;i<n;i++){
        g[i] = {w[i], i};
    }
    int s = 0;
    sort(g.begin(), g.end());
    vector<int> ans;
    for(int i = 0, j = 0;i<n;i++){
        s += g[i].F;
        while(s > u){
            s -= g[j].F;
            j++;
        }
        if(s >= l){
            for(int a = j;a<=i;a++){
                ans.push_back(g[a].S);
            }
            break;
        }
    }
    return ans;
}

Compilation message (stderr)

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
/usr/bin/ld: /tmp/cc3AqPhB.o: in function `main':
grader.cpp:(.text.startup+0x173): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status