Submission #959415

#TimeUsernameProblemLanguageResultExecution timeMemory
959415Mystic03Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms348 KiB
#include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { int p1 = 0; int r = 0; int currSum = 0; while (currSum < l) { currSum += w[r]; r++; } if (currSum <= u) { return std::vector<int>(w.begin(), w.begin() + r); } r--; currSum -= w[r]; for (int i = r; i < w.size(); i++) { currSum += w[i]; currSum -= w[p1++]; if (currSum >= l && currSum <= u) { return std::vector<int>(w.begin() + p1, w.end() + i + 1); } } return std::vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
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 = r; 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...