-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ02026.java
More file actions
40 lines (37 loc) · 1.02 KB
/
J02026.java
File metadata and controls
40 lines (37 loc) · 1.02 KB
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
package CODE_PTIT;
import java.util.*;
import java.lang.*;
public class J02026 {
static ArrayList<Integer> a = new ArrayList<>();
static int b[] = new int[15];
static int c[] = new int[15];
static void in(int n){
for(int i = 1; i <= n; i++){
System.out.print(a.get(i-1) + " ");
}
System.out.println();
}
static void Try(int i, int n, int k){
for(int j = b[i-1] + 1; j <= n-k+1; j++){
c[i] = a.get(j-1);
if(i == k) in(k);
else{
Try(i+1,n,k);
}
}
}
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
int t = inp.nextInt();
while(t-- > 0){
int n = inp.nextInt();
int k = inp.nextInt();
for(int i = 1; i <= n; i++){
int x = inp.nextInt();
a.add(x);
}
Collections.sort(a);
Try(1,n,k);
}
}
}