Submission #1354616

#TimeUsernameProblemLanguageResultExecution timeMemory
1354616putuputuDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
//#include "molecules.h"
vector<int> find_subset(int l, int u, vector<int> w){
	long long n=(int)w.size();
	vector< pair < long long, long long > > a(n, {0, -1});
    for(long long i=0; i<n; i++){
        a[i].first=w[i];
        a[i].second=i;
    }
	vector<long long> ans;
    sort(a.begin(), a.end());
    long long ll=0;
    long long sum=0;
    for(long long r=0; r<n; r++){
        sum+=a[r].first;
        while(sum>u and ll<=r ){
            sum-=a[ll].first;
            ll++;
        }
        if(sum>=l and sum<=u){
            for(long long i=ll; i<=r; i++){
                ans.push_back(a[i].second);
            }
            return ans;
        }

    }
    return ans;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:25:20: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   25 |             return ans;
      |                    ^~~
      |                    |
      |                    vector<long long int>
molecules.cpp:29:12: error: could not convert 'ans' from 'vector<long long int>' to 'vector<int>'
   29 |     return ans;
      |            ^~~
      |            |
      |            vector<long long int>