제출 #649583

#제출 시각아이디문제언어결과실행 시간메모리
649583tvladm2009Detecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include "molecules.h" using namespace std; typedef long long ll; vector<int> find_subset(int l, int u, vector<int> w) { sort(w.begin(), w.end()); int j = 0, sum = 0; int cnt = 0; vector<int> sol; for (int i = 0; i < w.size(); i++) { sum += w[i]; while (sum > u && j <= i) { sum -= w[j]; j++; } if (j <= i && l <= sum && sum <= u) { int cnt = i - j + 1; for (int k = 1; k <= cnt; k++) { sol.push_back(j + k - 1); } break; } } return sol; }

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:3: error: 'sort' was not declared in this scope; did you mean 'short'?
    8 |   sort(w.begin(), w.end());
      |   ^~~~
      |   short
molecules.cpp:12:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for (int i = 0; i < w.size(); i++) {
      |                   ~~^~~~~~~~~~
molecules.cpp:10:7: warning: unused variable 'cnt' [-Wunused-variable]
   10 |   int cnt = 0;
      |       ^~~