My issue
my output didn’t getting matched
My code
#include <iostream>
#include <vector>
using namespace std;
int max_students_cooking(const vector<int>& A, const vector<int>& B) {
int n = A.size();
int count = 0;
int current_time = 0;
for (int i = 0; i < n; ++i) {
if (current_time + B[i] <= A[i]) {
// If the sum of current time and cooking time is less than or equal to the scheduled finish time,
// the student can cook without violating the schedule
current_time += B[i];
count++;
}
}
return count;
}
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<int> A(N);
vector<int> B(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
for (int i = 0; i < N; ++i) {
cin >> B[i];
}
int result = max_students_cooking(A, B);
cout << result << endl;
}
return 0;
}
Learning course: Solve Programming problems using C++
Problem Link: Review problem - 5 Practice Problem in Solve Programming problems using C++ - CodeChef