import java.util.ArrayList;
import java.util.Scanner;
public class code {
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
Integer testCase = scan.nextInt();
ArrayList<Integer> result = new ArrayList<>();
if(testCase>=1 && testCase<=5)
{
for (int i = 0; i < testCase; i++)
{
scan.nextLine();
String str = scan.nextLine();
String[] string = str.split(" ");
Integer N = Integer.parseInt(string[0]);
Integer K = Integer.parseInt(string[1]);
Integer E = Integer.parseInt(string[2]);
Integer M = Integer.parseInt(string[3]);
if(K>=1 && K<N)
{
if(N>1 && N<10000)
{
if(M>1 && M<1000000000)
{
if(E>=1 && E<=4)
{
ArrayList<Integer> studentMarks = new ArrayList<>();
for (int j = 0; j < N; j++)
{
Integer sum=0;
String str1 = scan.nextLine();
String[] string1 = str1.split(" ");
for (int l = 0; l < string1.length; l++)
{
sum = sum+Integer.parseInt(string1[l]);
}
studentMarks.add(sum);
}
Integer his_marks = studentMarks.get(studentMarks.size()-1);
studentMarks.remove(studentMarks.size()-1);
for (int j = 1; j < studentMarks.size(); j++)
{
Integer key = studentMarks.get(j);
Integer k= j-1;
while(k>=0 && studentMarks.get(k)>key)
{
studentMarks.set(k+1, studentMarks.get(k));
k=k-1;
}
studentMarks.set(k+1,key);
}
Integer minimum_marks =studentMarks.get((studentMarks.size()-(N-K)));
Integer required = (minimum_marks-his_marks)+1;
result.add(required);
}
}
}
}
}
}
for (Integer integer : result) {
System.out.println(integer);
}
}
}
Whatβs wrng with this one? Getting NZEC error!