Language: C++

#include <iostream>

using namespace std;
int N, M, K;
int time = 0;
int countA = 0;
int countB = 0;

int main() {
    cin >> N >> M >> K;
    if ((N <= 200000 && N >= 1) && (M <= 200000 && M >= 1) && (K >= 1 && K <= 1000000000)) {
        int *A = new int[N + 1];
        int *B = new int[M + 1];
        for (int i = 1; i < N + 1; i++)
            cin >> A[i];
        for (int i = 1; i < M + 1; i++)
            cin >> B[i];
        while (time <= K) {
            if (countB != M && countA != N) {
                if (A[countA + 1] < B[countB + 1]) {
                    time += A[countA + 1];
                    countA++;
                } else {
                    time += B[countB + 1];
                    countB++;
                }
            } else if (countB == M && countA != N) {
                time += A[countA + 1];
                countA++;
            } else if (countA == N && countB != M) {
                time += B[countB + 1];
                countB++;
            } else
                break;
        }
        if (time > K)
            cout << countA + countB - 1 << endl;
        else
            cout << countA + countB << endl;
        delete[]A;
        A = NULL;
        delete[]B;
        B = NULL;
    }
    return 0;
}

Compiler output:
a.cc:5:5: error: 'int time' redeclared as different kind of entity
    5 | int time = 0;
      |     ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 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/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:18:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   18 |         while (time <= K) {
      |                ~~~~~^~~~
a.cc:21:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   21 |                     time += A[countA + 1];
      |                     ~~~~~^~~~~~~~~~~~~~~~
a.cc:21:26: error: assignment of read-only location 'time'
a.cc:24:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   24 |                     time += B[countB + 1];
      |                     ~~~~~^~~~~~~~~~~~~~~~
a.cc:24:26: error: assignment of read-only location 'time'
a.cc:28:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |                 time += A[countA + 1];
      |                 ~~~~~^~~~~~~~~~~~~~~~
a.cc:28:22: error: assignment of read-only location 'time'
a.cc:31:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |                 time += B[countB + 1];
      |                 ~~~~~^~~~~~~~~~~~~~~~
a.cc:31:22: error: assignment of read-only location 'time'
a.cc:36:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   36 |         if (time > K)
      |             ~~~~~^~~