답안 #309446

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309446 2020-10-03T14:00:50 Z cig32 Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include "molecules.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,l,u;
    cin >> n >> l>>u;
    pair<ll,ll> w[n];
    bool used[n];
    ll tot_sum=0;
    for(int i=0;i<n;i++)cin>>w[i].first;
    for(int i=0;i<n;i++)w[i].second=i;
    for(int i=0;i<n;i++)tot_sum+=w[i].first;
    for(int i=0;i<n;i++)used[i]=false;
    sort(w,w+n);
    ll curr_sum=0, pt=0, nani=0;
    for(int i=0;i<n;i++){
        curr_sum+=w[i].first;
        if(u<curr_sum){
            curr_sum-=w[i].first;
            pt=i;
            break;
        }
        used[i]=true;
        nani++;
        if(l<=curr_sum&&curr_sum<=u){
            cout<<nani<<"\n";
            for(int j=0;j<n;j++){
                if(used[j])cout<<w[j].second<<" ";
            }
            cout<<"\n";
            return 0;
        }
    }
    for(int i=0;i<min(n-pt,pt);i++){
        curr_sum-=w[i].first;
        used[i]=false;
        curr_sum+=w[n-i-1].first;
        used[n-i-1]=true;
        if(l<=curr_sum&&curr_sum<=u){
            break;
        }
    }
    if(l<=curr_sum&&curr_sum<=u){
        cout << nani << "\n";
        for(int i=0;i<n;i++){
            if(used[i]) cout<<w[i].second<<" ";
        }
    }
    else{
        cout<<"0\n";
    }
}

Compilation message

/tmp/ccFVYOfx.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc4Srk0J.o:molecules.cpp:(.text.startup+0x0): first defined here
/tmp/ccFVYOfx.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