Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<float>v(a,a+n);
    sort(v.begin(),v.end());
    int ai = (int)v[n-1];
    int aj;
    std::vector<int>::iterator low,up;
    low = lower_bound(v.begin(),v.end(),ai/2.0);
//    up = upper_bound(v.begin(),v.end(),ai/2.0);
    if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
        aj= (int)v[low-v.begin()-1];
    }else{
        aj= (int)v[low-v.begin()];
    }
    cout << ai << " " << aj << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:47: error: no match for 'operator=' (operand types are 'std::vector<int>::iterator' and '__gnu_cxx::__normal_iterator<float*, std::vector<float> >')
   18 |     low = lower_bound(v.begin(),v.end(),ai/2.0);
      |                                               ^
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<int*, std::vector<int> >& __gnu_cxx::__normal_iterator<int*, std::vector<int> >::operator=(const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&)'
 1038 |     class __normal_iterator
      |           ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<float*, std::vector<float> >' to 'const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&'
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<int*, std::vector<int> >& __gnu_cxx::__normal_iterator<int*, std::vector<int> >::operator=(__gnu_cxx::__normal_iterator<int*, std::vector<int> >&&)'
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<float*, std::vector<float> >' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >&&'
a.cc:20:13: error: no match for 'operator-' (operand types are 'std::vector<int>::iterator' and 'std::vector<float>::iterator')
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |          ~~~^~~~~~~~~~
      |          |          |
      |          |          __normal_iterator<float*,vector<float>>
      |          __normal_iterator<int*,vector<int>>
/usr/include/c++/14/bits/stl_iterator.h:1148:7: note: candidate: '__gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-(difference_type) const [with _Iterator = int*; _Container = std::vector<int>; difference_type = long int]'
 1148 |       operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1148:33: note:   no known conversion for argument 1 from 'std::vector<float>::iterator' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'}
 1148 |       operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
      |                 ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:20:22: note:   'std::vector<int>::iterator' is not derived from 'const std::reverse_iterator<_Iterator>'
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |                      ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:20:22: note:   'std::vector<int>::iterator' is not derived from 'const std::move_iterator<_IteratorL>'
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |                      ^
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1312 |     operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note:   template argument deduction/substitution failed:
a.cc:20:22: note:   deduced conflicting types for parameter '_Container' ('std::vector<int>' and 'std::vector<float>')
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |                      ^
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note: candidate: 'template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1325 |     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note:   template argument deduction/substitution failed:
a.cc:20:22: note:   deduced conflicting types for parameter '_Iterator' ('int*' and 'float*')
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |                      ^
a.cc:20:46: error: no match for 'operator-' (operand types are 'std::vector<int>::iterator' and 'std::vector<float>::iterator')
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |                                           ~~~^~~~~~~~~~
      |                                           |          |
      |                                           |          __normal_iterator<float*,vector<float>>
      |                                           __normal_iterator<int*,vector<int>>
/usr/include/c++/14/bits/stl_iterator.h:1148:7: note: candidate: '__gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-(difference_type) const [with _Iterator = int*; _Container = std::vector<int>; difference_type = long int]'
 1148 |       operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1148:33: note:   no known conversion for argument 1 from 'std::vector<float>::iterator' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'}
 1148 |       operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
      |                 ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:20:55: note:   'std::vector<int>::iterator' is not derived from 'const std::reverse_iterator<_Iterator>'
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |                                                       ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:20:55: note:   'std::vector<int>::iterator' is not derived from 'const std::move_iterator<_IteratorL>'
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |                                                       ^
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1312 |     operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note:   template argument deduction/substitution failed:
a.cc:20:55: note:   deduced conflicting types for parameter '_Container' ('std::vector<int>' and 'std::vector<float>')
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |                                                       ^
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note: candidate: 'template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1325 |     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note:   template argument deduction/substitution failed:
a.cc:20:55: note:   deduced conflicting types for parameter '_Iterator' ('int*' and 'float*')
   20 |     if(v[low-v.begin()]-ai/2.0 > ai/2.0-v[low-v.begin()-1]){
      |                                                       ^
a.cc:21:23: error: no match for 'operator-' (operand types are 'std::vector<int>::iterator' and 'std::vector<float>::iterator')
   21 |         aj= (int)v[low-v.begin()-1];
      |                    ~~~^~~~~~~~~~
      |                    |          |
      |                    |          __normal_iterator<float*,vector<float>>
      |                    __normal_iterator<int*,vector<int>>
/usr/include/c++/14/bits/stl_iterator.h:1148:7: note: candidate: '__gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-(difference_type) const [with _Iterator = int*; _Container = std::vector<int>; difference_type = long int]'
 1148