output_description: Print the minimum value of $P$ in a line.
input_description: In the first line, two integers $n$ and $k$ are given separated by a space
  character. In the following $n$ lines, $w_i$ are given respectively.
attempt: from itertools import combinations
  
  
  def func(w, partition):
      sum_list = [sum(w[0 : partition[0]])]
      for i in range(len(partition)):
          if i < len(partition) - 1:
              sum_list.append(sum(w[partition[i] : partition[i + 1]]))
          else:
              sum_list.append(sum(w[partition[i] :]))
  
      return max(sum_list)
  
  
  n, k = [int(x) for x in input().split()]
  w = [int(input()) for _ in range(n)]
  
  w_indices = [i for i in range(1, n)]
  partition_list = combinations(w_indices, k - 1)
  p_list = []
  for partition in partition_list:
      p_list.append(func(w, partition))
  
  print(min(p_list))
  
problem_description: Input
  
  In the first line, two integers $n$ and $k$ are given separated by a space
  character. In the following $n$ lines, $w_i$ are given respectively.
samples: [{"input": "5 3\n    8\n    1\n    7\n    3\n    9", "output": "10\n    \n\nIf the first truck loads two packages of $\\\\{8, 1\\\\}$, the second truck loads\ntwo packages of $\\\\{7, 3\\\\}$ and the third truck loads a package of $\\\\{9\\\\}$,\nthen the minimum value of the maximum load $P$ shall be 10."}, {"input": "4 2\n    1\n    2\n    2\n    6", "output": "6\n    \n\nIf the first truck loads three packages of $\\\\{1, 2, 2\\\\}$ and the second\ntruck loads a package of $\\\\{6\\\\}$, then the minimum value of the maximum load\n$P$ shall be 6."}]