제출 #856003

#제출 시각아이디문제언어결과실행 시간메모리
856003IS_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; 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:9:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    9 |     sort(a.begin(), a.end());
      |     ^~~~
      |     short
molecules.cpp:10:5: error: 'priority_queue' was not declared in this scope
   10 |     priority_queue<int>pq;
      |     ^~~~~~~~~~~~~~
molecules.cpp:3:1: note: 'std::priority_queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    2 | #include "molecules.h"
  +++ |+#include <queue>
    3 | using namespace std;
molecules.cpp:10:20: error: expected primary-expression before 'int'
   10 |     priority_queue<int>pq;
      |                    ^~~
molecules.cpp:15:13: error: 'pq' was not declared in this scope
   15 |             pq.push(i);
      |             ^~
molecules.cpp:17:21: error: 'pq' was not declared in this scope
   17 |             curr-=a[pq.top()].first;
      |                     ^~
molecules.cpp:24:12: error: 'pq' was not declared in this scope
   24 |     while(!pq.empty()){
      |            ^~