Minimum cost to convert all elements of a K-size subarray to 0 from given Ternary Array with subarray sum as cost

import java.io.*;import java.util.Arrays;class GFG{           static int minCost(int arr[], int N, int K)    {                       int pcount1[] = new int[N + 1];                       int pcount2[] = new int[N + 1];        Arrays.fill(pcount1, 0);        Arrays.fill(pcount2, 0);                for (int i = 1; i