Help me in solving NODRUGS problem

My issue

Getting internal server error. I was getting same error while solving other problems too.

My code

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

int main(){
	int t=0;int n=0;int l=0;int k=0;
	cin>>t;
	while(t--){
		cin>>n>>k>>l;
		int arr[n];
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		if(l<=1 || k <=0){
			cout<<"NO"<<endl;
		}else{
			int m=0;
			for(int i=0;i<n;i++){
				if(arr[i] > m){
					m = arr[i];
				}
			}
			int j=1;
			while(j<l){
					arr[n-1] += k;
					j++;
			}
			//cout<<arr[n-1]<<endl;
			if(arr[n-1]<=m){
				cout<<"NO"<<endl;
			}else{
				cout<<"YES"<<endl;
			}
			
			
		}


	}





	return 0;
}

Problem Link: CodeChef: Practical coding for everyone

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n,k,l;
cin>>n>>k>>l;
vector s(n);
int maxi = 0;
for(int i=0; i<n; i++)
{
cin>>s[i];
maxi = max(maxi,s[i]);
}

    int count = 0;

    for(int i=0; i<n; i++)
    {
        count += s[i] == maxi;
    }

    if(s[n-1] == maxi && count == 1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        s[n-1] += (l-1)*k;

        int curr_max = 0;
        for(int i=0; i<n; i++)
        {
            curr_max = max(curr_max,s[i]);
        }
        count = 0;
        for(int i=0; i<n; i++) count += s[i] == curr_max;
        if(s[n-1] == curr_max && count == 1)
        {
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
}

return 0;
}