제출 #856010

#제출 시각아이디문제언어결과실행 시간메모리
856010IS_RushdiDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { int n = w.size(); vector<pair<int,int>>a; for(int i = 0; i < n; i++) a.push_back({w[i],i}); sort(a.begin(), a.end()); priority_queue<int>pq; long long curr = 0; for(int i = n-1; i >= 0; i--){ if(curr < l){ curr += a[i].first; pq.push(i); }else if(curr > u){ curr-=a[pq.top()].first; pq.pop(); curr+=a[i].first; pq.push(i); }else break; } vector<int>ans; if(curr < l || curr > r){return ans;} while(!pq.empty()){ ans.push_back(a[pq.top()].second); pq.pop(); } return ans; } // int main(){ // }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:24:27: error: 'r' was not declared in this scope
   24 |     if(curr < l || curr > r){return ans;}
      |                           ^