-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ02012.java
More file actions
30 lines (27 loc) · 825 Bytes
/
J02012.java
File metadata and controls
30 lines (27 loc) · 825 Bytes
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
import java.util.*;
import java.math.*;
public class J02012 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
ArrayList<Integer> x = new ArrayList<>();
x.add(a[0]);
System.out.println("Buoc " + 0 + ": " + x.get(0));
for (int i = 1; i < n; i++) {
int j = 0;
while (j < x.size() && x.get(j) < a[i]) {
j++;
}
x.add(j, a[i]);
System.out.print("Buoc " + i + ": ");
for (int g : x) {
System.out.print(g + " ");
}
System.out.println("");
}
}
}