Submission #305924

# Submission time Handle Problem Language Result Execution time Memory
305924 2020-09-24T05:25:49 Z kylych03 Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
#include "grader.cpp"
using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector <int> res;
    vector <long long> pr;
    vector <pair<int, int> > a;
    a.resize(w.size());
    pr.resize(w.size()+1);

    for(int i = 0 ; i < w.size(); i++){
        a[i].first = w[i];
        a[i].second = i;
    }
    sort(a.begin(), a.end());

    pr[0]=0;
    for(int i = 0 ; i < w.size(); i++){
        pr[i+1] =pr[i] + a[i].first;
    }
    int cnt=0;
    for(int i=1;i<=a.size(); i++){
        if(pr[i] - pr[cnt] > u ){
            cnt++;
        }
        if(pr[i] - pr[cnt] <= u && pr[i] - pr[cnt]>=l){
            for(int j = cnt;j<i; j++ )
                res.push_back(a[j].second);
            break;
        }

    }

    return res;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i = 0 ; i < w.size(); i++){
      |                     ~~^~~~~~~~~~
molecules.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0 ; i < w.size(); i++){
      |                     ~~^~~~~~~~~~
molecules.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=1;i<=a.size(); i++){
      |                 ~^~~~~~~~~~
/tmp/cclkVN9h.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccZSsOjv.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status