-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathp234.java
37 lines (25 loc) · 792 Bytes
/
p234.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.Arrays;
import java.util.Scanner;
public class p234 {
public static void main(String[] args) {
final Scanner s = new Scanner(System.in);
int casos = s.nextInt();
int pilas, min, left, right, res;
int[] arr;
while (casos-- != 0) {
pilas = s.nextInt();
min = s.nextInt();
arr = new int[pilas];
for (int i = 0; i < pilas; i++) arr[i] = s.nextInt();
Arrays.sort(arr);
left = 0;
right = pilas - 1;
res = 0;
while (left < right) {
if (arr[left] + arr[right] >= min) { right--; res++; }
left++;
}
System.out.println( res );
}
}
}