Submission #3588647
Source Code Expand
import java.util.Scanner; public class Main { public static void main(String[] args) { int N; int[] A; int[] sortPattern1; int[] sortPattern2; int sa; int saGoukei1 = 0; int saGoukei2 = 0; Scanner sc = null; try { sc = new Scanner(System.in); N = Integer.valueOf(sc.nextInt()); A = new int[N]; for (int i = 0; i < N; i++) { A[i] = Integer.valueOf(sc.nextInt()); if (i >= 1) { for (int j = i; j > 0; j--) { if (A[j - 1] > A[j]) { int temp = A[j]; A[j] = A[j - 1]; A[j - 1] = temp; } else { break; } } } } int midIdx; if (N % 2 == 0) midIdx = N / 2 - 1; else midIdx = N / 2; sortPattern1 = new int[N]; sortPattern1[0] = A[midIdx]; boolean largeSideFlg = true; int counter1 = 1; int sortCounter = 1; // 差分が最大になるようにソート for (int i = N - counter1; i != midIdx;) { sortPattern1[sortCounter] = A[i]; sa = sortPattern1[sortCounter - 1] - sortPattern1[sortCounter]; if (sa < 0) sa = -sa; saGoukei1 += sa; sortCounter++; if (largeSideFlg) { i = counter1 - 1; largeSideFlg = false; } else { counter1++; largeSideFlg = true; i = N - counter1; } } // sortPattern2 = new int[N]; // sortPattern2[0] = A[midIdx]; // // boolean smallSideFlg = true; // int counter2 = 0; // int sortCounter2 = 1; // // 差分が最大になるようにソート // for (int i = counter2; sortCounter2 != N;) { // sortPattern2[sortCounter2] = A[i]; // sortCounter2++; // if (smallSideFlg) { // smallSideFlg = false; // i = N - counter2 - 1; // } else { // counter2++; // i = counter2; // smallSideFlg = true; // } // } // // for (int i = 0; i < N - 1; i++) { // sa = sortPattern2[i] - sortPattern2[i + 1]; // if (sa < 0) // sa = -sa; // saGoukei2 += sa; // } // // if (saGoukei1 > saGoukei2) System.out.println(saGoukei1); // else // System.out.println(saGoukei2); } catch (Exception e) { System.out.println(e); } finally { if (sc != null) { sc.close(); } } } }
Submission Info
Submission Time | |
---|---|
Task | C - Align |
User | ProgrammerTT |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 2372 Byte |
Status | WA |
Exec Time | 2111 ms |
Memory | 51248 KB |
Judge Result
Set Name | Sample | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | TLE | 2109 ms | 48320 KB |
02.txt | TLE | 2108 ms | 48904 KB |
03.txt | TLE | 2105 ms | 48448 KB |
04.txt | TLE | 2109 ms | 47648 KB |
05.txt | TLE | 2108 ms | 48456 KB |
06.txt | TLE | 2109 ms | 49168 KB |
07.txt | TLE | 2109 ms | 48688 KB |
08.txt | TLE | 2108 ms | 49496 KB |
09.txt | TLE | 2109 ms | 49152 KB |
10.txt | TLE | 2111 ms | 48764 KB |
11.txt | TLE | 2109 ms | 47772 KB |
12.txt | TLE | 2109 ms | 50440 KB |
13.txt | TLE | 2105 ms | 47736 KB |
14.txt | TLE | 2109 ms | 49048 KB |
15.txt | TLE | 2109 ms | 47512 KB |
16.txt | TLE | 2108 ms | 49520 KB |
17.txt | TLE | 2109 ms | 49196 KB |
18.txt | TLE | 2109 ms | 51248 KB |
19.txt | TLE | 2105 ms | 48932 KB |
20.txt | TLE | 2109 ms | 48708 KB |
21.txt | TLE | 2105 ms | 46764 KB |
22.txt | TLE | 2105 ms | 47256 KB |
23.txt | TLE | 2109 ms | 47692 KB |
24.txt | TLE | 2105 ms | 47344 KB |
25.txt | TLE | 2082 ms | 44892 KB |
26.txt | TLE | 2074 ms | 47568 KB |
27.txt | TLE | 2049 ms | 48616 KB |
28.txt | TLE | 2104 ms | 48004 KB |
29.txt | AC | 406 ms | 45844 KB |
30.txt | WA | 490 ms | 47964 KB |
31.txt | WA | 417 ms | 50292 KB |
32.txt | WA | 457 ms | 49784 KB |
33.txt | AC | 99 ms | 18900 KB |
34.txt | AC | 97 ms | 21716 KB |
35.txt | AC | 96 ms | 19284 KB |
36.txt | WA | 97 ms | 20692 KB |
37.txt | AC | 98 ms | 22612 KB |
s1.txt | AC | 98 ms | 19668 KB |
s2.txt | AC | 98 ms | 19284 KB |
s3.txt | WA | 97 ms | 21588 KB |