Problem binarysearch
User proplayermason
Submission Time 2026-06-25 16:11:24
Score 0
Max Time N/A
Max Memory N/A

Compile Error

binarysearch.cpp: In function ‘int main()’:
binarysearch.cpp:15:37: error: no match for ‘operator-’ (operand types are ‘int’ and ‘std::vector<int>::iterator’ {aka ‘__gnu_cxx::__normal_iterator<int*, std::vector<int> >’})
15 | int ans=( a. begin(), a. end(), k) - a. begin();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~
| | |
| int std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
from /usr/include/c++/9/bits/specfun.h:45,
from /usr/include/c++/9/cmath:1927,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
from binarysearch.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:415:5: note: candidate: ‘template<class _IteratorL, class _I