Problem code: HOTEL . what wrong in my code... it gives runtime error

this is my code for the problem ., it gives me a runtime error.

#include <bits/stdc++.h>
using namespace std;


int main() {
	int t;cin>>t;
	while(t--){
	    int n; cin>>n;
	    int k=0;
	    int arrival[25]={0};
	    int departure[25]={0};
	    for(int i=0;i<n;i++){
	        cin>>k;
	        arrival[k]++;
	        
	    }
	    for(int i=0;i<n;i++){
	        cin>>k;
	        departure[k]++;
	    }
	    
	    int maxGuests=0,guests=0;
	    for(int time=0;time<25;time++){
	        guests=guests-departure[time]+arrival[time];
	        maxGuests=max(maxGuests,guests);
	    }
	    cout<<maxGuests<<endl;
	}
	return 0;
}

please tell my mistake.

1 Like

“All arrival/departure times will be between 1 and 1000, inclusive”

But in your code:

	    int arrival[25]={0};
	    int departure[25]={0};

251001

1 Like