Source Code
#include <iostream>
#include<algorithm>


using namespace std;
int main() {
  int n , k  ;
  cin>>n>>k;
  int a[n];
  double total = 0 , minn=199999999999;
  for(int i =0 ; i<n ; i++)
    {
      cin>>a[i];
      total +=a[i];
      }
     
    for(int i = 0 ; i< n; i++)
      {
        double sum = total ;
        for(int j = i ; j<n ; j+=k)
          sum -= a[j];
        minn=min(sum,minn);
      }
  cout<<minn;
  
  
}
Copy
Offer Tala_Ibraheem
GNU G++17
1 ms
184 KB
Wrong Answer