Submission #3996354
Source Code Expand
# coding:utf-8 import sys from collections import Counter, deque INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def S(): return input() N = I() A = [I() for _ in range(N)] A.sort() B = deque() state = 1 for i in range(N // 2): if state: B.append(A[i]) B.appendleft(A[-(i + 1)]) else: B.append(A[-(i + 1)]) B.appendleft(A[i]) state ^= 1 if N % 2: C = deque(B) B.append(A[N // 2]) C.appendleft(A[N // 2]) ans1 = 0 ans2 = 0 for i in range(N - 1): ans1 += abs(B[i] - B[i + 1]) ans2 += abs(C[i] - C[i + 1]) print(max(ans1, ans2))
Submission Info
Submission Time | |
---|---|
Task | C - Align |
User | uni745e |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 781 Byte |
Status | RE |
Exec Time | 842 ms |
Memory | 8988 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 | AC | 820 ms | 8984 KB |
02.txt | AC | 821 ms | 8860 KB |
03.txt | RE | 134 ms | 8092 KB |
04.txt | AC | 822 ms | 8856 KB |
05.txt | AC | 820 ms | 8864 KB |
06.txt | RE | 127 ms | 8092 KB |
07.txt | AC | 831 ms | 8856 KB |
08.txt | AC | 828 ms | 8988 KB |
09.txt | RE | 132 ms | 8092 KB |
10.txt | AC | 827 ms | 8860 KB |
11.txt | AC | 834 ms | 8860 KB |
12.txt | RE | 127 ms | 8092 KB |
13.txt | AC | 825 ms | 8864 KB |
14.txt | AC | 820 ms | 8860 KB |
15.txt | RE | 126 ms | 8096 KB |
16.txt | AC | 842 ms | 8860 KB |
17.txt | AC | 822 ms | 8988 KB |
18.txt | RE | 126 ms | 8092 KB |
19.txt | AC | 835 ms | 8860 KB |
20.txt | AC | 827 ms | 8864 KB |
21.txt | RE | 126 ms | 8088 KB |
22.txt | AC | 823 ms | 8856 KB |
23.txt | AC | 828 ms | 8860 KB |
24.txt | RE | 136 ms | 8088 KB |
25.txt | AC | 796 ms | 5732 KB |
26.txt | AC | 791 ms | 5736 KB |
27.txt | RE | 101 ms | 4968 KB |
28.txt | AC | 793 ms | 5732 KB |
29.txt | AC | 772 ms | 5748 KB |
30.txt | RE | 88 ms | 6512 KB |
31.txt | AC | 787 ms | 7324 KB |
32.txt | AC | 784 ms | 7284 KB |
33.txt | RE | 21 ms | 3316 KB |
34.txt | RE | 21 ms | 3316 KB |
35.txt | RE | 22 ms | 3316 KB |
36.txt | AC | 21 ms | 3316 KB |
37.txt | AC | 21 ms | 3316 KB |
s1.txt | AC | 21 ms | 3316 KB |
s2.txt | RE | 21 ms | 3316 KB |
s3.txt | AC | 21 ms | 3316 KB |