Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;



int main() {
    int64_t n,m,k;
    cin >> n >> m >> k;
    vector<int64_t> v1(n);
    vector<int64_t> v2(m);
    rep(i,n){
        cin >> v1[i];
    }
    rep(i,m){
        cin >> v2[i];
    }
    int64_t ans=0;
    vector<int64_t> tot1(n);
    vector<int64_t> tot2(m);
    rep(i,n){
        if(i!=0) tot1[i]=v1[i]+tot1[i-1];
        else tot1[i]=v1[i];
    }
    rep(i,m){
        if(i!=0) tot2[i]=v2[i]+tot2[i-1];
        else tot2[i]=v2[i];
    }
    rep(i,n){
        int64_t x=k-tot1[i];
        if(x<0) break;
        if(x==0) ans=max(ans,i+1);
        int64_t begin=0;
        int64_t end=m-1;
        while(end!=-1){
            int64_t mid=(begin+end)/2;
            if(tot2[m-1]<=x){
                ans=m+i+1;
            }
            if(tot2[mid]>x){
                end=mid;
            }
            else{
                begin=mid;
            }
            if(begin+1==end){
                if(tot2[end]<=x){
                    begin=end;
                }
                else end=begin;
            }
            if(begin==end){
                ans=max(ans,i+begin+2);
                end=-1;
            }
        }
        
    }
    cout << ans << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:25: error: no matching function for call to 'max(int64_t&, int)'
   33 |         if(x==0) ans=max(ans,i+1);
      |                      ~~~^~~~~~~~~
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:33:25: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   33 |         if(x==0) 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
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:33:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   33 |         if(x==0) ans=max(ans,i+1);
      |                      ~~~^~~~~~~~~