제출 #265837

#제출 시각아이디문제언어결과실행 시간메모리
265837amallaDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define ll long long vector<int> find_subset(int l, int u, vector<int> w) { int N = w.size(); vector<pair<int,int>> A(N); for (int i = 0; i<N; ++i) { A[i].first = w[i]; A[i].second = i; } sort(A.begin(), A.end()); ll sum = 0; queue<int> q; for (int i = 0; i<N; ++i) { sum += A[i].first; q.push(A[i].second); while (sum>u) { sum -= A[q.front()]; q.pop(); } if (sum>=l) { vector<int> Ans(q.size()); j = 0; while(!q.empty()) { Ans[j] = q.front(); q.pop(); ++j; } return Ans; } } return vector<int>(0); }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:21:17: error: no match for 'operator-=' (operand types are 'long long int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   21 |             sum -= A[q.front()];
molecules.cpp:26:13: error: 'j' was not declared in this scope
   26 |             j = 0;
      |             ^