Submission #82869

# Submission time Handle Problem Language Result Execution time Memory
82869 2018-11-02T09:10:09 Z SecretAgent007 Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
//#include "molecules.h"
#include <bits/stdc++.h>


using namespace std;

vector<int> find_subset(int l, int r, vector<int> w){
    int n = w.size();
    vector< pair<int, int> > toS(0);
    for(int i = 0; i < w.size(); i++){
        toS.push_back(make_pair(w[i],i));
    }
    sort(toS.begin(), toS.end());
    int le = 0;
    int ri = 0;
    long long sum = 0;
    while(1){
        while(ri < n && sum < l){
            sum+=toS[ri++].first;
        }
        while(le < n && sum  > r){
            sum-=toS[le++].first;
        }



        if(sum >= l && sum < r){
            vector<int> ans(0);
            for(int i = le; i <= ri; i++){
                ans.push_back(toS[i].second);
            }
            return ans;
        }
        if(le >= n || ri >= n) break;
    }
    vector<int> ans(0);
    return ans;
}
signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> v(0);
    for(int i = 0; i < a; i++){
        int d;
        cin >> d;
        v.push_back(d);
    }
    v = find_subset(b,c,v);
    cout << v.size() << endl;
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << ' ';
    }
    cout << endl;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < w.size(); i++){
                    ~~^~~~~~~~~~
molecules.cpp: In function 'int main()':
molecules.cpp:50:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size(); i++){
                    ~~^~~~~~~~~~
/tmp/cco6cXSO.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccxIjxcK.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status