Submission #1026372

#TimeUsernameProblemLanguageResultExecution timeMemory
1026372ezzzayDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
#define pb push_back
#define ff first
#define ss second
signed main(){
    int l,u;
    cin>>l>>u;
    int n;
    cin>>n;
    vector<int> w;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        w.pb(a);
    }
    vector<pair<int,int>>vc;
    for(int i=0;i<n;i++){
        vc.pb({w[i],i});
    }
    sort(vc.begin(),vc.end());
    int L=0,R=-1;
    int s=0;
    int x=-1,y=-1;
    while(1){
        if(s<l){
            R++;
            s+=vc[R].ff;
        }
        else if(l<=s and s<=u){
            x=L;
            y=R;
            break;
        }
        else{
            s-=vc[L].ff;
            L++;
        }
        if(R==n-1)break;
    }
    vector<int>ans;
    for(int i=x;i<=y;i++){
        ans.pb(vc[i].ss);
    }
    return ans;
}

Compilation message (stderr)

molecules.cpp: In function 'int main()':
molecules.cpp:46:12: error: cannot convert 'std::vector<int>' to 'int' in return
   46 |     return ans;
      |            ^~~