I have created an array of objects of class and then sorted them accordingly but I am still getting TLE error.
import java.util.*;
public class a {
static class Employee{
int salary;
String name;
Employee(String nam,int sal)
{
salary=sal;name=nam;
}
void display()
{
System.out.println(name+" "+salary);
}
}
public static void main(String args[]) {
// Your Code Here
Scanner obj = new Scanner(System.in);
int x = obj.nextInt();
int n = obj.nextInt();
Employee list[]=new Employee[n];
for (int i = 0; i < n; i++) {
list[i]=new Employee(obj.next(),obj.nextInt());
}
// Arrays.sort(list);
for (int i = 0; i < n - 1; i++)
for (int j = 0; j < n - 1 - i; j++) {
if (list[j].salary < list[j + 1].salary
|| (list[j].salary == list[j + 1].salary && list[j].name.compareTo(list[j + 1].name) > 0)) {
Employee temp;
temp = list[j];
list[j] = list[j + 1];
list[j + 1] = temp;
}
}
for (int i = 0; i < n; i++) {
if(list[i].salary>=x)
list[i].display();
}
}
}