Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int main(){
	int n, k;
	cin >> n >> k;
	int neg = 0, pos = 0, zero = 0;
	vector<ll> posis, negs, a;
	for(int i = 0; i < n; i++){
		ll cur;
		cin >> cur;
		if(cur == 0){
			zero++;
		}else if(cur < 0){
			neg++;
			negs.push_back(-cur);
			a.push_back(-cur);
		}else{
			pos++;
			posis.push_back(cur);
			a.push_back(cur);
		}
	}
	sort(a.begin, a.end());
	sort(posis.begin(), posis.end());
	sort(negs.begin(), negs.end());
	ll sol = 1, count = 0;
	if(pos >= k){
		for(int i = posis.size() - 1; i >= 0; i--){
			if(count == k) break;
			sol = (sol * posis[i]) % MOD;
			count++;
		}
		cout << sol << '\n';
	}else if(pos + neg >= k && neg > 1){
		for(int i = n - 1; i >= 0; i--){
			sol = (sol * a[i]) % MOD;
			count++;
		}
		cout << sol << '\n';
	}else if (pos + neg + zero >= k){
		cout << 0 << '\n';
	}else{
		for(int i = 0; i < negs.size(); i++){
			sol = ((sol * negs[i])) % MOD;
		}
		cout << (sol + MOD) % MOD << '\n';
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:13: error: no matching function for call to 'sort(<unresolved overloaded function type>, std::vector<long long int>::iterator)'
   29 |         sort(a.begin, a.end());
      |         ~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >]'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:32: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |          ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided