제출 #949798

#제출 시각아이디문제언어결과실행 시간메모리
949798Rainmaker2627Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; std::vector<int> find_subset(int l, int u, std::vector<int> w) { ll s=0; int lo=0, hi=0, n=w.size(); vector<int> ans(0); vector<pair<int, int>> t; for (int i = 0; i < n; ++i) t.emplace_back(w[i], i); sort(t.begin(), t.end()); while (lo<n) { if (s<l) { if (hi<n) s+=h[hi++].first; else break; } else if (s>u && lo<n) s-=h[lo++].first; if (l<=s && s<=u) { for (int i = lo; i < hi; ++i) ans.push_back(t[i].second); break; } } return ans; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:17: error: 'h' was not declared in this scope
   15 |    if (hi<n) s+=h[hi++].first;
      |                 ^
molecules.cpp:17:30: error: 'h' was not declared in this scope
   17 |   } else if (s>u && lo<n) s-=h[lo++].first;
      |                              ^