Help me in solving NOTIME problem

My issue

what’s wrong with my code

My code

#include <iostream>
using namespace std;

int main() {
	int n,h,x;
	cin>>n>>h>>x;
	int tym[n];
	for(int i=0;i<n;i++){
	    cin>>tym[i];
	}
	int j=1;
	while(j<n){
	    for(int i=0;i<n-j;i++){
	        if(tym[j]<tym[j+1]){
	            int temp=tym[j];
	            tym[j]=tym[j+1];
	            tym[j+1]=temp;
	        }
	    }
	    j++;
	}
	int reqd= h-x;
	if(tym[n-1]>=reqd){
	    cout<<"YES"<<endl;
	}
	else{
	    cout<<"NO"<<endl;
	    
	    
	}
	
	
	return 0;
}

Problem Link: NOTIME Problem - CodeChef

@raman067
U are making mistake in sorting part i have corrected it in your code.
First u have written j instead of i inside for loop and second is it should be a[i]>a[i+1].

#include <iostream>
using namespace std;

int main() {
	int n,h,x;
	cin>>n>>h>>x;
	int tym[n];
	for(int i=0;i<n;i++){
	    cin>>tym[i];
	}
	int j=1;
	while(j<n){
	    for(int i=0;i<n-j;i++){
	        if(tym[i]>tym[i+1]){
	            int temp=tym[i];
	            tym[i]=tym[i+1];
	            tym[i+1]=temp;
	        }
	    }
	    j++;
	}
	int reqd= h-x;
	if(tym[n-1]>=reqd){
	    cout<<"YES"<<endl;
	}
	else{
	    cout<<"NO"<<endl;
	    
	    
	}
	
	
	return 0;
}