Language: C++

#include <iostream>

namespace ABC172
{
  static const int N_MAX = 200001;
  std::vector<int> Ai = {};
  std::vector<int> Bi = {};

  class C
  {
  public:
    C() = default;
    ~C() = default;

    void Run()
    {
      int N = {};
      int M = {};
      int K = {};
      std::cin >> N;
      std::cin >> M;
      std::cin >> K;
      Ai.reserve(N_MAX);
      Bi.reserve(N_MAX);

      for (int i = 0; i < N; ++i)
      {
        int v;
        std::cin >> v;
        Ai.push_back(v);
      }
      for (int i = 0; i < M; ++i)
      {
        int v;
        std::cin >> v;
        Bi.push_back(v);
      }

      int answer = 0;

      int max_A = 0;
      int max_B = 0;

      auto Calc = [&](auto& v1, auto& v2, int v1end)
      {
        // v1優先で読み進める
        int rest = K;
        int num = 0;
        for (int i=0;i<v1end :++i)
        {
          auto v = v1.at(i);
          rest -= v;
          if (rest >= 0) {
            num++;
          } else {
            break;
          }
        }
        if (rest > 0) {
          for (auto v : v2)
          {
            rest -= v;
            if (rest >= 0) {
              num++;
            }
            else {
              break;
            }
          }
          return num;
        }
      };

      // Ai優先時の最善手を二部探索で探す
      int best_A = 0;
      {
        auto upper = Ai.size();
        auto lower = Ai.size() / 2;
        auto A1 = (Ai, Bi, upper);
        auto A2 = (Ai, Bi, lower);
        while (A1 != A2)
        {
          int dif = (upper - lower) * 0.5f;
          if (dif == 0) break;
          if (A1 > A2) {
            lower += dif;
            A2 = (Ai, Bi, lower);
          }
          else {
            upper -= dif;
            A1 = (Ai, Bi, upper);
          }
        }
        best_A = A1;
      }

      int best_B = 0;
      {
        auto upper = Bi.size();
        auto lower = Bi.size() / 2;
        auto A1 = (Bi, Ai, upper);
        auto A2 = (Bi, Ai, lower);
        while (A1 != A2)
        {
          int dif = (upper - lower) * 0.5f;
          if (dif == 0) break;
          if (A1 > A2) {
            lower += dif;
            A2 = (Bi,Ai, lower);
          }
          else {
            upper -= dif;
            A1 = (Bi, Ai, upper);
          }
        }
        best_B = A1;
      }

      answer = best_A > best_B ? best_A : best_B;

      std::cout << answer << std::endl;
    }
  };

}



int main()
{

  ABC172::C prob;
  prob.Run();

  return 0;
}


Compiler output:
a.cc:6:8: error: 'vector' in namespace 'std' does not name a template type
    6 |   std::vector<int> Ai = {};
      |        ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
a.cc:7:8: error: 'vector' in namespace 'std' does not name a template type
    7 |   std::vector<int> Bi = {};
      |        ^~~~~~
a.cc:7:3: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    7 |   std::vector<int> Bi = {};
      |   ^~~
a.cc: In member function 'void ABC172::C::Run()':
a.cc:23:7: error: 'Ai' was not declared in this scope
   23 |       Ai.reserve(N_MAX);
      |       ^~
a.cc:24:7: error: 'Bi' was not declared in this scope
   24 |       Bi.reserve(N_MAX);
      |       ^~
a.cc: In lambda function:
a.cc:49:22: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   49 |         for (int i=0;i<v1end :++i)
      |                      ^
a.cc:49:30: error: expected ';' before ':' token
   49 |         for (int i=0;i<v1end :++i)
      |                              ^
a.cc:59:9: error: expected primary-expression before 'if'
   59 |         if (rest > 0) {
      |         ^~
a.cc:59:9: error: expected ';' before 'if'
a.cc:59:9: error: expected primary-expression before 'if'
a.cc:59:9: error: expected ')' before 'if'
a.cc:49:13: note: to match this '('
   49 |         for (int i=0;i<v1end :++i)
      |             ^