結果

問題 No.1374 Absolute Game
ユーザー 👑 KazunKazun
提出日時 2021-02-05 21:45:57
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 1,089 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 98,184 KB
最終ジャッジ日時 2023-09-15 07:34:49
合計ジャッジ時間 6,015 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,636 KB
testcase_01 AC 93 ms
71,764 KB
testcase_02 AC 94 ms
71,464 KB
testcase_03 AC 94 ms
71,636 KB
testcase_04 AC 94 ms
71,780 KB
testcase_05 AC 92 ms
71,580 KB
testcase_06 AC 93 ms
71,760 KB
testcase_07 AC 94 ms
71,956 KB
testcase_08 AC 131 ms
81,580 KB
testcase_09 AC 156 ms
93,572 KB
testcase_10 AC 160 ms
95,148 KB
testcase_11 AC 141 ms
86,996 KB
testcase_12 AC 130 ms
82,464 KB
testcase_13 AC 145 ms
89,912 KB
testcase_14 AC 167 ms
98,168 KB
testcase_15 AC 170 ms
98,052 KB
testcase_16 AC 170 ms
97,824 KB
testcase_17 AC 169 ms
98,184 KB
testcase_18 AC 166 ms
98,172 KB
testcase_19 AC 166 ms
97,884 KB
testcase_20 AC 134 ms
83,420 KB
testcase_21 AC 140 ms
85,876 KB
testcase_22 AC 166 ms
97,716 KB
testcase_23 AC 116 ms
77,860 KB
testcase_24 AC 116 ms
77,920 KB
testcase_25 AC 120 ms
79,100 KB
testcase_26 AC 128 ms
82,448 KB
testcase_27 AC 137 ms
85,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
from collections import deque

N=int(input())
C=list(map(int,input().split()))
C.sort()

T=[]
for i,j in product([0,1],repeat=2):
    Q=deque(C[:])
    a=b=0
    for k in range(N):
        if k%2==0:
            if i==0:
                x=Q.popleft()
            else:
                x=Q.pop()
            a+=x
        else:
            if j==0:
                y=Q.popleft()
            else:
                y=Q.pop()
            b+=y
    T.append(abs(a)-abs(b))

nn,np,pn,pp=T
print(max(min(nn,np),min(pn,pp)))
0