Language: C++

#include <iostream>

using namespace std;
int N, M, K;
int time = 0, countA = 0, 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, countA = 0, countB = 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:16:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |         while (time <= K) {
      |                ~~~~~^~~~
a.cc:19:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |                     time += A[countA + 1];
      |                     ~~~~~^~~~~~~~~~~~~~~~
a.cc:19:26: error: assignment of read-only location 'time'
a.cc:22:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |                     time += B[countB + 1];
      |                     ~~~~~^~~~~~~~~~~~~~~~
a.cc:22:26: error: assignment of read-only location 'time'
a.cc:26:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   26 |                 time += A[countA + 1];
      |                 ~~~~~^~~~~~~~~~~~~~~~
a.cc:26:22: error: assignment of read-only location 'time'
a.cc:29:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |                 time += B[countB + 1];
      |                 ~~~~~^~~~~~~~~~~~~~~~
a.cc:29:22: error: assignment of read-only location 'time'
a.cc:34:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   34 |         if (time > K)
      |             ~~~~~^~~