Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t N,M,K;
  cin >> N >> M >> K;
  int a=0;int b=0;
  int64_t ans=0;
  std::vector<int64_t> A(N);
  std::vector<int64_t> B(M);
    cin >> A.at(0);
  for (int i = 1; i < N; ++i)
    {
      cin >> a;
      A.at(i) = a+A.at(i-1);
    }
    cin >> B.at(0);
  for (int i = 1; i < M; ++i)
    {
      cin >> b;
      B.at(i) = b+B.at(i-1);
    }

  if(A.at(0)<=K){
  for (int i = 0; i < N; ++i){
    int left = 0;
    int right = M-1;
    for (int x = 0; x < log2(200001)+10; ++x){ 
      int64_t mid = (left+right)/2;
      if(K-A.at(i)<B.at(mid)){
        right = mid ;  
      }else{
        left = mid ;
      }
    }

      if(A.at(i)+B.at(right)<=K){
        ans = max(ans,i+right+2);
      }else if(A.at(i)+B.at(left)<=K){
        ans = max(ans,i+left+2);
      }else if(A.at(i)<=K){
        ans = max(ans,i+1);
      }
  }
  }else{
    for (int i = 0; i < M; ++i)
    {
      if(B.at(i)>K){
        ans = i;
        break;
      }
    }
  }

  cout << ans << endl;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:38:18: error: no matching function for call to 'max(int64_t&, int)'
   38 |         ans = max(ans,i+right+2);
      |               ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:38:18: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   38 |         ans = max(ans,i+right+2);
      |               ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:38:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   38 |         ans = max(ans,i+right+2);
      |               ~~~^~~~~~~~~~~~~~~
a.cc:40:18: error: no matching function for call to 'max(int64_t&, int)'
   40 |         ans = max(ans,i+left+2);
      |               ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:40:18: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   40 |         ans = max(ans,i+left+2);
      |               ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:40:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   40 |         ans = max(ans,i+left+2);
      |               ~~~^~~~~~~~~~~~~~
a.cc:42:18: error: no matching function for call to 'max(int64_t&, int)'
   42 |         ans = max(ans,i+1);
      |               ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:42:18: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   42 |         ans = max(ans,i+1);
      |               ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:42:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   42 |         ans = max(ans,i+1);
      |               ~~~^~~~~~~~~