public class CodingTest {

public static void main(String[] args) {

int T, test_case, result, MAX;

Scanner sc = new Scanner(System.in);

T = sc.nextInt();

for(test_case = 0; test_case < T; test_case++){

int N = sc.nextInt();

result = 0;

ArrayList<Integer> temp = new ArrayList<Integer>();

for (int i = 0; i < N; i++) {

temp.add(sc.nextInt());

}

Collections.sort(temp);

MAX = temp.get(temp.size()-1);

System.out.println(MAX - N + 1);

for (int i = 0 ; i < N; i++) {

if (temp.get(i) + (N-i) >= MAX + 1) {

result++;

}

}

System.out.println("Case #"+(test_case+1));

System.out.println(result);

}

}

}


이렇게 풀엇는데 오답계속 뜬다......

님들은 어케 풀엇음??

내 코드에서 오류가 잇나요??