Submission #959413

#TimeUsernameProblemLanguageResultExecution timeMemory
959413Mystic03Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 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.end()); } r--; currSum -= w[r]; for (int i = r; i < n; i++) { currSum += w[r]; currSum -= w[p1++]; if (currSum >= l && currSum <= u) { return std::vector<int>(w.begin(), w.end()); } } 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:25: error: 'n' was not declared in this scope
   20 |     for (int i = r; i < n; i++) {
      |                         ^