답안 #50193

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50193 2018-06-08T08:29:31 Z hugo_pm Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
using namespace std;

vector<int> solve(int l, int u, vector<int> w)
{
    vector<pair<int, int>> rafin(w.size());
    for (int i = 0; i < (int)(w.size()); ++i) rafin[i] = {w[i], i+1};
    sort(rafin.begin(), rafin.end());
    sort(w.begin(), w.end());
    int somme = 0;
    int k = w.size() - 1;
    int i = k;
    while ((somme < l || somme > u) && (i >= 0 && k >= 0))
    {
        if (somme < l) { somme += w[i]; --i; }
        else { somme -= w[k]; --k; }
    }
    if (somme < l || somme > u) return {};
    ++i;
    vector<int> ans(k-i+1);
    for (int o = i; o <= k; ++o) ans[o-i] = rafin[o].second;
    return ans;
}

Compilation message

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