답안 #71817

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71817 2018-08-25T16:24:26 Z XmtosX Detecting Molecules (IOI16_molecules) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
    vector <int> ans;
    pair <int,int> p[200005];
    int n=w.size();
    for (int i=0;i<n;i++)
    {
        p[i]={w[i],i};
    }
    sort(p,p+n);
    int cur=0;
    for (int i=0,j=0;j<n;j++)
    {
        cur+= (p[j].first);
        while (cur>u)
        {
            cur-=p[i].first;
            i++;
        }
        if (cur>=l)
        {
            for (int q=i;q<=j;q++)
            {
                ans.push_back(p[q].second);
            }
            return ans;
        }
    }
    return ans;
}
int main() {
    int n, l, u;
    assert(3 == scanf("%d %d %d", &n, &l, &u));
    std::vector<int> w(n);
    for (int i = 0; i < n; i++)
        assert(1 == scanf("%d", &w[i]));
    std::vector<int> result = find_subset(l, u, w);


    printf("%d\n", (int)result.size());
    for (int i = 0; i < (int)result.size(); i++)
        printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]);
}

Compilation message

/tmp/ccpE1yWN.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccSDD9Pw.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status