답안 #309453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309453 2020-10-03T14:02:52 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){
          vector<int>v;
            for(int j=0;j<n;j++){
                if(used[j])v.push_back(w[j].second);
            }
            return v;
        }
    }
    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){
        vector<int>v;
        for(int i=0;i<n;i++){
            if(used[i])v.push_back(w[i].second);
   
        }
      return v;
    }
    else{
        vector<int>v;
      return v;
    }
}

Compilation message

molecules.cpp: In function 'int main()':
molecules.cpp:31:20: error: cannot convert 'std::vector<int>' to 'int' in return
   31 |             return v;
      |                    ^
molecules.cpp:49:14: error: cannot convert 'std::vector<int>' to 'int' in return
   49 |       return v;
      |              ^
molecules.cpp:53:14: error: cannot convert 'std::vector<int>' to 'int' in return
   53 |       return v;
      |              ^