-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP234.java
69 lines (38 loc) · 929 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package aceptaelreto;
import java.util.*;
public class P234 {
static Scanner s;
static long sumaArray(long[] n, int m, long v) {
Arrays.sort(n);
int left = 0;
int right = m - 1;
int resp = 0;
while(left < right) {
if(n[left] + n[right] >= v) {
right--;
resp++;
}
left++;
}
return resp;
}
static void llegir(long[] n, long m){
for(int i = 0; i < m; i++)
n[i] = s.nextLong();
}
static void cas() {
int n;
long v;
long[] piles;
n = s.nextInt();
v = s.nextLong();
piles = new long[n];
llegir(piles, n);
System.out.println(sumaArray(piles, n,v));
}
public static void main(String[] args) {
s = new Scanner(System.in);
int n = s.nextInt();
for (int i = 0; i <n; i++) cas();
}
}