Submission #377320

#TimeUsernameProblemLanguageResultExecution timeMemory
377320antontsiorvasDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms364 KiB
#include <cstdio> #include <algorithm> #include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { std:sort(w.begin(),w.end()); int cursum = 0; std::vector<int> ret; int beg=0, end=0; while(end < w.size()){ if(l <= cursum && cursum <= u){ for(int i=beg; i<end; i++){ ret.push_back(w[i]); } return ret; } if(cursum < l){ cursum += w[end]; end++; } else if(cursum > u){ cursum -= w[beg]; beg++; } } return ret; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     while(end < w.size()){
      |           ~~~~^~~~~~~~~~
molecules.cpp:6:5: warning: label 'std' defined but not used [-Wunused-label]
    6 |     std:sort(w.begin(),w.end());
      |     ^~~
#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...