제출 #959413

#제출 시각아이디문제언어결과실행 시간메모리
959413Mystic03Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
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); }

컴파일 시 표준 에러 (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++) {
      |                         ^