Submission #3588625
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; try (Scanner 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 { } } }
Submission Info
Submission Time | |
---|---|
Task | C - Align |
User | ProgrammerTT |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 2308 Byte |
Status | WA |
Exec Time | 2109 ms |
Memory | 51976 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 | 2108 ms | 47168 KB |
02.txt | TLE | 2105 ms | 47208 KB |
03.txt | TLE | 2108 ms | 50060 KB |
04.txt | TLE | 2109 ms | 47664 KB |
05.txt | TLE | 2105 ms | 49188 KB |
06.txt | TLE | 2105 ms | 48888 KB |
07.txt | TLE | 2108 ms | 47776 KB |
08.txt | TLE | 2108 ms | 49664 KB |
09.txt | TLE | 2109 ms | 47128 KB |
10.txt | TLE | 2108 ms | 49516 KB |
11.txt | TLE | 2108 ms | 47984 KB |
12.txt | TLE | 2108 ms | 49616 KB |
13.txt | TLE | 2109 ms | 48288 KB |
14.txt | TLE | 2109 ms | 48544 KB |
15.txt | TLE | 2108 ms | 49912 KB |
16.txt | TLE | 2105 ms | 51976 KB |
17.txt | TLE | 2108 ms | 49392 KB |
18.txt | TLE | 2105 ms | 47600 KB |
19.txt | TLE | 2109 ms | 50704 KB |
20.txt | TLE | 2109 ms | 49772 KB |
21.txt | TLE | 2105 ms | 45960 KB |
22.txt | TLE | 2105 ms | 48408 KB |
23.txt | TLE | 2108 ms | 47872 KB |
24.txt | TLE | 2105 ms | 47484 KB |
25.txt | TLE | 2051 ms | 46192 KB |
26.txt | TLE | 2063 ms | 46532 KB |
27.txt | TLE | 2067 ms | 48604 KB |
28.txt | TLE | 2075 ms | 48708 KB |
29.txt | AC | 385 ms | 49200 KB |
30.txt | WA | 495 ms | 46968 KB |
31.txt | WA | 470 ms | 50552 KB |
32.txt | WA | 486 ms | 48808 KB |
33.txt | AC | 95 ms | 19540 KB |
34.txt | AC | 97 ms | 19156 KB |
35.txt | AC | 96 ms | 22612 KB |
36.txt | WA | 96 ms | 18900 KB |
37.txt | AC | 97 ms | 19284 KB |
s1.txt | AC | 96 ms | 19796 KB |
s2.txt | AC | 97 ms | 21588 KB |
s3.txt | WA | 98 ms | 19156 KB |