-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
36 lines (33 loc) · 1.13 KB
/
Solution.java
File metadata and controls
36 lines (33 loc) · 1.13 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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int d = sc.nextInt();
int []a = new int[n];
int []da = new int[d];
int []sa = new int[n-d];
System.out.println("n=" + n + " d=" + d);
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
//System.out.println(Arrays.toString(a));
for (int j = 0; j < n; j++) {
if (j < d) {
da[j] = a[j];
//System.out.println("da=" + Arrays.toString(da));
} else if (j>=d) {
sa[j-d] = a[j];
//System.out.println("sa=" + Arrays.toString(sa));
}
}
System.arraycopy(sa, 0, a, 0, sa.length);
System.arraycopy(da, 0, a, sa.length, da.length);
System.out.println(Arrays.toString(a));
}
}