405054: GYM101755 G Underpalindromity
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
G. Underpalindromitytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
Let us call underpalindromity of array b of length k the minimal number of times one need to increment some elements bj by 1 so that the array b would become a palindrome, that is, b1 = bk, b2 = bk - 1, and so on.
The array of length n, consisting of integers, is given. Consider all its subarrays of length k, and for each of these subarrays its underpalindromity pi. It's needed to calculate sum of all pi (1 ≤ i ≤ n - k + 1).
InputThe first line contains two integers n and k (1 ≤ k ≤ n ≤ 200000) — the length of the array and the length of subarrays.
The second line contains n integers ai ( - 108 ≤ ai ≤ 108) — the elements of the array.
OutputOutput a single integer — sum of underpalindromities of all subarrays of length k.
ExamplesInput3 2Output
3 1 2
3Input
5 3Output
2 3 3 1 4
4