Language: C++

#include<bits/stdc++.h>
#include<math.h>
using namespace std;

int main(){
  int n;
  int *k;
  int s=0;
  cin >> n;
  vector<int>v(2*n);
  for(int i;i<2*n;i++){
    cin >> v[i];
  }
  for(int i;i<n;i++){
    s+=min_element(0,v.size());
    k=&(min_element(0,v.size()));
    v.erase(k);
     k=&(min_element(0,v.size()));
     v.erase(k);
  }
  cout << s;
  return 0;
}
    
    


Compiler output:
a.cc: In function 'int main()':
a.cc:15:19: error: no matching function for call to 'min_element(int, std::vector<int>::size_type)'
   15 |     s+=min_element(0,v.size());
      |        ~~~~~~~~~~~^~~~~~~~~~~~
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:5577:12: note: candidate: 'template<class _FIter> constexpr _FIter std::min_element(_FIter, _FIter)'
 5577 |     inline min_element(_ForwardIterator __first, _ForwardIterator __last)
      |            ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5577:12: note:   template argument deduction/substitution failed:
a.cc:15:19: note:   deduced conflicting types for parameter '_FIter' ('int' and 'long unsigned int')
   15 |     s+=min_element(0,v.size());
      |        ~~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5602:5: note: candidate: 'template<class _FIter, class _Compare> constexpr _FIter std::min_element(_FIter, _FIter, _Compare)'
 5602 |     min_element(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5602: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:516:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::min_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare)'
  516 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Compare __comp);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:516:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:520:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::min_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
  520 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:520:1: note:   candidate expects 3 arguments, 2 provided
a.cc:16:20: error: no matching function for call to 'min_element(int, std::vector<int>::size_type)'
   16 |     k=&(min_element(0,v.size()));
      |         ~~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5577:12: note: candidate: 'template<class _FIter> constexpr _FIter std::min_element(_FIter, _FIter)'
 5577 |     inline min_element(_ForwardIterator __first, _ForwardIterator __last)
      |            ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5577:12: note:   template argument deduction/substitution failed:
a.cc:16:20: note:   deduced conflicting types for parameter '_FIter' ('int' and 'long unsigned int')
   16 |     k=&(min_element(0,v.size()));
      |         ~~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5602:5: note: candidate: 'template<class _FIter, class _Compare> constexpr _FIter std::min_element(_FIter, _FIter, _Compare)'
 5602 |     min_element(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5602:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:516:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::min_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare)'
  516 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Compare __comp);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:516:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:520:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::min_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
  520 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:520:1: note:   candidate expects 3 arguments, 2 provided
a.cc:17:12: error: no matching function for call to 'std::vector<int>::erase(int*&)'
   17 |     v.erase(k);
      |     ~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'int*' to 'std::vector<int>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided
a.cc:18:21: error: no matching function for call to 'min_element(int, std::vector<int>::size_type)'
   18 |      k=&(min_element(0,v.size()));
      |          ~~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5577:12: note: candidate: 'template<class _FIter> constexpr _FIter std::min_element(_FIter, _FIter)'
 5577 |     inline min_element(_ForwardIterator __first, _ForwardIterator __last)
      |            ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5577:12: note:   template argument deduction/substitution failed:
a.cc:18:21: note:   deduced conflicting types for parameter '_FIter' ('int' and 'long unsigned int')
   18 |      k=&(min_element(0,v.size()));
      |          ~~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5602:5: note: candidate: 'template<class _FIter, class _Compare> constexpr _FIter std::min_element(_FIter, _FIter, _Compare)'
 5602 |     min_element(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5602:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:516:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::min_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare)'
  516 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Compare __comp);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:516:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:520:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::min_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
  520 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:520:1: note:   candidate expects 3 arguments, 2 provided
a.cc:19:13: error: no matching function for call to 'std::vector<int>::erase(int*&)'
   19 |      v.erase(k);
      |      ~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'int*' to 'std::vector<int>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided