title: Minimum Increment K Operations Make Elements Equal
signature: fun minimumIncrementKOperationsMakeElementsEqual(arr: ArrayList<Int>, n: Int, k: Int): Int {
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;
  }
question_info.test_list: [{"idx": 0, "outputs": 10, "inputs": {"arr": [4, 7, 19, 16], "n": 4, "k": 3}}, {"idx": 1, "outputs": 0, "inputs": {"arr": [4, 4, 4, 4, 4], "n": 5, "k": 3}}, {"idx": 2, "outputs": 24, "inputs": {"arr": [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], "n": 39, "k": 1}}, {"idx": 3, "outputs": -1, "inputs": {"arr": [85, 36, 52, 8, 52, 15, 16], "n": 5, "k": 6}}, {"idx": 4, "outputs": 36, "inputs": {"arr": [-10, -5, -5, -20, 10, 30], "n": 6, "k": 5}}, {"idx": 5, "outputs": -1, "inputs": {"arr": [0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0], "n": 10, "k": 15}}, {"idx": 6, "outputs": -1, "inputs": {"arr": [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], "n": 26, "k": 33}}, {"idx": 7, "outputs": -1, "inputs": {"arr": [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], "n": 34, "k": 3}}, {"idx": 8, "outputs": -1, "inputs": {"arr": [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], "n": 39, "k": 10}}, {"idx": 9, "outputs": 892, "inputs": {"arr": [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], "n": 18, "k": 1}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(arr: ArrayList<Int>, n: Int, k: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(arr, n, k), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(arrayListOf(4, 7, 19, 16), 4, 3, 10)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(4, 4, 4, 4, 4), 5, 3, 0)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(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)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(85, 36, 52, 8, 52, 15, 16), 5, 6, -1)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-10, -5, -5, -20, 10, 30), 6, 5, 36)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0), 10, 15, -1)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(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)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(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)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(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)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(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)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: minimumIncrementKOperationsMakeElementsEqual
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn