Task: | Järjestys |
Sender: | planckcons |
Submission time: | 2016-10-05 20:00:33 +0300 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.12 s | 1 | details |
#2 | WRONG ANSWER | 0.21 s | 2 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
import java.util.Scanner; import static java.lang.System.arraycopy; import java.util.Arrays; import java.util.Collections; public class Jarjestys { static int[] arr; static int n; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); arr = new int[n]; for(int i = 0; i < n; i++) { arr[i] = scan.nextInt(); } String fin = ""; for(int i = n; i > 0; i--) { fin += finder(i) + " "; } System.out.println(n); System.out.println(fin); } public static int[] swap(int n2, int[] arr, int p) { int a = n2-(p+1); int[] arr2 = new int[n2]; int[] arr3 = new int[a]; arraycopy(arr, 0, arr2, a, p+1); arraycopy(arr, p+1, arr3, 0, a); Collections.reverse(Arrays.asList(arr3)); arraycopy(arr3, 0, arr2, 0, a); return arr2; } static int finder(int i) { for(int j = 0; j < i; j++) { if(arr[j] == i) { arr = swap(i ,arr, j); return j+1; } } return 0; } }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
10 9 3 4 7 6 5 10 2 8 1 |
correct output |
---|
32 10 10 9 10 9 8 7 9 4 2 1 4 5 2... |
user output |
---|
10 7 4 7 4 1 1 4 3 1 1 |
Test 2
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 650 716 982 41 133 1000 876 92... |
correct output |
---|
3984 207 207 206 207 128 127 126 12... |
user output |
---|
1000 6 91 35 665 359 848 761 301 15... |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 94703 47808 62366 31885 7091 8... |
correct output |
---|
399956 98676 98676 98675 98676 62994 ... |
user output |
---|
(empty) |