Hello There . Hopefuly You will help me solve my TLE problem . I decided to get rid of array that stores input data and came up with this. I am getting TLE where I thought my code would be more efficient than using array for this . anyone else have problem with Java solution ? some tips for making this code faster ?
Scanner sc = new Scanner(System.in);
int ip = sc.nextInt();
int heroes;
int towers;
int damage;
int currentHero;
for (int i = 0; i < ip; i++) {
int count=0;
heroes = sc.nextInt();
towers = sc.nextInt();
damage= sc.nextInt();
for(int ii=0; ii<heroes;ii++){
currentHero = sc.nextInt();
while(currentHero>damage){
currentHero-=damage;
count++;
}
}
if(count>=towers){
System.out.println("YES");
}else{
System.out.println("NO");
}
}