Task: | Järjestys |
Sender: | planckcons |
Submission time: | 2016-10-06 14:59:37 +0300 |
Language: | Java |
Status: | READY |
Result: | 56 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 19 |
#2 | ACCEPTED | 37 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.14 s | 1 | details |
#2 | ACCEPTED | 0.22 s | 2 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
import java.util.Scanner;import java.util.ArrayList;import java.util.List;import java.util.Collections;import java.util.ListIterator;public class Jarjestys3 {static int n;static int c;static List list;public static void main(String[] args) {Scanner scan = new Scanner(System.in);int n = scan.nextInt();int uno = 0;list = new ArrayList();for(int i = 0; i < n; i++){int a = scan.nextInt();list.add(a);if(a == 1)uno = i + 1;}String fin = uno + " ";reverse(list, uno);for(int i = 2; i < n; i++){fin += deleting(i);}fin += (n-1);System.out.println((c+2) + " " + fin);}public static String deleting(int i){int a = list.indexOf(i);list.remove(a);c += 2;return (a + i - 2) + " " + (a + i - 1) + " ";}public static void reverse(List<?> l, int n){ListIterator i1 = l.listIterator();int pos1 = 1;int pos2 = n;ListIterator i2 = l.listIterator(pos2);while (pos1 < pos2){Object o1 = i1.next();Object o2 = i2.previous();i1.set(o2);i2.set(o1);++pos1;--pos2;}}}
Test details
Test 1
Group: 1
Verdict: ACCEPTED
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 |
---|
18 10 2 3 8 9 8 9 6 7 7 8 8 9 ... |
Test 2
Group: 2
Verdict: ACCEPTED
input |
---|
1000 650 716 982 41 133 1000 876 92... |
correct output |
---|
3984 207 207 206 207 128 127 126 12... |
user output |
---|
1998 207 80 81 712 713 491 492... |
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) |