結果

問題 No.1391 ±1 Abs Sum
ユーザー ygd.ygd.
提出日時 2021-02-12 21:50:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 279 bytes
コンパイル時間 697 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 103,984 KB
最終ジャッジ日時 2023-09-27 03:42:01
合計ジャッジ時間 6,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,604 KB
testcase_01 AC 71 ms
71,444 KB
testcase_02 AC 72 ms
71,396 KB
testcase_03 AC 71 ms
71,176 KB
testcase_04 AC 69 ms
71,316 KB
testcase_05 WA -
testcase_06 AC 71 ms
71,400 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 98 ms
94,788 KB
testcase_15 AC 102 ms
96,936 KB
testcase_16 AC 109 ms
103,084 KB
testcase_17 AC 104 ms
99,740 KB
testcase_18 AC 122 ms
100,124 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 127 ms
101,164 KB
testcase_32 AC 97 ms
92,644 KB
testcase_33 AC 100 ms
96,920 KB
testcase_34 WA -
testcase_35 AC 73 ms
71,420 KB
testcase_36 AC 127 ms
101,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
A = list(map(int,input().split()))

#Aの最小値をx
P0 = sum(A) - A[0]*N
Q0 = sum(A[K:]) - A[0]*(N-K)
#print(P0,Q0)

#Aの最大値をx
PN = A[N-1]*N - sum(A)
QN = A[N-1]*(N-K) - sum(A[:N-K])
#print(PN,QN)

ans = min(P0-2*Q0, PN-2*QN)
print(ans)
0