title: Minimum Increment K Operations Make Elements Equal
signature: class Solution {
  
      public int MinimumIncrementKOperationsMakeElementsEqual(List<int> arr, int n, int k) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(int actual, int expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(List<int> arr, int n, int k, int expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                int pred_result = solution_cls.PLACEHOLDER_FN_NAME(arr, n, k); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  new List<int>{4, 7, 19, 16}, 4, 3, 
                  10
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{4, 4, 4, 4, 4}, 5, 3, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 39, 1, 
                  24
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{85, 36, 52, 8, 52, 15, 16}, 5, 6, 
                  -1
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-10, -5, -5, -20, 10, 30}, 6, 5, 
                  36
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0}, 10, 15, 
                  -1
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{1, 5, 5, 9, 11, 12, 12, 13, 13, 14, 16, 18, 26, 26, 28, 28, 30, 31, 32, 37, 37, 38, 40, 43, 44, 45, 47, 47, 55, 58, 60, 62, 63, 64, 69, 78, 83, 84, 92, 96, 96, 99}, 26, 33, 
                  -1
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{76, -78, 92, -98, 16, 44, 86, 96, -8, 2, -96, 74, -28, 12, 54, -40, -64, -12, 4, 48, 68, -82, 8, 0, -4, 88, 48, -54, 90, 62, -84, 76, -48, 62, -80, -94, 38, -4, 36}, 34, 3, 
                  -1
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 39, 10, 
                  -1
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{62, 99, 29, 23, 55, 30, 79, 63, 1, 88, 59, 8, 11, 80, 23, 51, 97, 32, 80, 48, 84, 36, 73, 59, 1, 34, 92, 10}, 18, 1, 
                  892
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
source_py: def minimum_increment_k_operations_make_elements_equal(arr, n, k):
      max1 = max(arr)
      res = 0
      for i in range(0, n):
          if (((max1 - arr[i]) % k) != 0):
              return (- 1)
          else:
              res += ((max1 - arr[i]) / k)
      return int(res)
source_cpp: int minimum_increment_k_operations_make_elements_equal(vector<int> arr, int n, int k) {
    int max = * max_element(arr.begin(), arr.end());
    int res = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( ( max - arr [ i ] ) % k != 0 ) return - 1;
      else res += ( max - arr [ i ] ) / k;
    }
    return res;
  }