結果
問題 | No.1391 ±1 Abs Sum |
ユーザー | shotoyoo |
提出日時 | 2021-02-12 22:06:33 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 591 bytes |
コンパイル時間 | 466 ms |
コンパイル使用メモリ | 86,856 KB |
実行使用メモリ | 130,496 KB |
最終ジャッジ日時 | 2023-09-27 04:10:35 |
合計ジャッジ時間 | 8,582 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 69 ms
71,292 KB |
testcase_01 | AC | 69 ms
71,524 KB |
testcase_02 | RE | - |
testcase_03 | AC | 69 ms
71,384 KB |
testcase_04 | WA | - |
testcase_05 | RE | - |
testcase_06 | WA | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | AC | 122 ms
105,004 KB |
testcase_15 | WA | - |
testcase_16 | AC | 129 ms
102,084 KB |
testcase_17 | WA | - |
testcase_18 | AC | 137 ms
111,480 KB |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | AC | 150 ms
119,380 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | RE | - |
testcase_35 | AC | 66 ms
71,484 KB |
testcase_36 | RE | - |
ソースコード
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") n,k = list(map(int, input().split())) a = list(map(int, input().split())) cum = [0] v = 0 for i in range(n): v += a[i] cum.append(v) l = 0 ans = float("inf") for i in range(n): x = a[i] while l<i and l<k and x - a[l] > a[k+l-1] - x: l += 1 val = cum[l] - (cum[i] - cum[l]) + (cum[k+l] - cum[i]) - (cum[n] - cum[k+l]) ans = min(ans, val + x * (n - 2*k - 4*l + 2*i)) # print(i,l,val,x * (n - 2*k - 4*l + 2*i)) print(ans)