Submission #472844

#TimeUsernameProblemLanguageResultExecution timeMemory
472844Erik_GepardDetecting Molecules (IOI16_molecules)C++14
19 / 100
1 ms296 KiB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

std::vector<int> find_subset(int ll, int uu, std::vector<int> w) {
    long long n=w.size();
    long long l=ll;
    long long u=uu;
    vector<pair<long long, long long> > a(w.size());
    for(long long i=0; i<w.size(); i++){
        a[i].first=w[i];
        a[i].second=i;
    }
    sort(a.begin(), a.end());
    long long sum=0;
    long long j=0;
    long long helyesi=-1, helyesj=-1;
    for(long long i=0; i<n; i++){
        while(sum<l && j<n){
            sum+=w[j];
            j++;
        }
        if(sum<=u && sum>=l){
            helyesi=i;
            helyesj=j;
        }
        sum-=a[i].first;
    }
    vector<int> ans;
    for(long long i=helyesi; i<helyesj; i++){
        ans.push_back(a[i].second);
    }
    if(helyesi!=-1) return ans;
    else return vector<int>(0);
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(long long i=0; i<w.size(); i++){
      |                        ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...