結果

問題 No.2835 Take and Flip
ユーザー timitimi
提出日時 2024-08-09 21:26:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 353 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,224 KB
実行使用メモリ 109,248 KB
最終ジャッジ日時 2024-08-09 21:26:22
合計ジャッジ時間 3,464 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,124 KB
testcase_01 AC 38 ms
53,412 KB
testcase_02 AC 39 ms
52,332 KB
testcase_03 AC 103 ms
102,212 KB
testcase_04 AC 97 ms
101,812 KB
testcase_05 AC 36 ms
52,280 KB
testcase_06 AC 115 ms
108,192 KB
testcase_07 AC 117 ms
108,944 KB
testcase_08 AC 111 ms
106,360 KB
testcase_09 AC 133 ms
103,204 KB
testcase_10 AC 129 ms
103,344 KB
testcase_11 AC 133 ms
103,480 KB
testcase_12 AC 138 ms
103,736 KB
testcase_13 AC 132 ms
103,108 KB
testcase_14 AC 76 ms
81,804 KB
testcase_15 AC 38 ms
53,564 KB
testcase_16 AC 97 ms
95,120 KB
testcase_17 AC 47 ms
63,556 KB
testcase_18 AC 104 ms
102,412 KB
testcase_19 AC 119 ms
109,248 KB
testcase_20 AC 72 ms
78,168 KB
testcase_21 AC 121 ms
108,664 KB
testcase_22 AC 95 ms
98,384 KB
testcase_23 AC 62 ms
76,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# N,M,K=map(int, input().split())
# D=[[] for i in range(N)]
# for i in range(M):
#   a,b,d=map(int, input().split())
#   a-=1;b-=1
#   D[a].append((d,b));D[b].append((d,a))

N=int(input())
A=list(map(int, input().split()))
A=sorted(A)[::-1]
x,y=0,-1;f,s=0,0
for i in range(N):
  if i%2==0:
    f+=A[x]
    x+=1 
  else:
    s+=A[y]
    y-=1 
print(f+s)
0