n, k = map(int, input().split())
W = [int(input()) for i in range(n)]

left = max(W)-1; right = sum(W)
while left+1 < right:
    mid = (left + right) // 2
    cnt = 1; cur = 0
    for w in W:
        if mid < cur + w:
            cur = w
            cnt += 1
        else:
            cur += w
    if cnt <= k:
        right = mid
    else:
        left = mid
print(right) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input W = [int(input()) for i in range(n)] W [int(input()) for i in range(n)] left = max(W)-1 left max(W)-1 max(W) max W 1 right = sum(W) right sum(W) sum W while left+1 < right:
    mid = (left + right) // 2
    cnt = 1; cur = 0
    for w in W:
        if mid < cur + w:
            cur = w
            cnt += 1
        else:
            cur += w
    if cnt <= k:
        right = mid
    else:
        left = mid left+1 < right left+1 left 1 right mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 cnt = 1 cnt 1 cur = 0 cur 0 for w in W:
        if mid < cur + w:
            cur = w
            cnt += 1
        else:
            cur += w
     w W if mid < cur + w:
            cur = w
            cnt += 1
        else:
            cur += w
     mid < cur + w mid cur + w cur w cur = w cur w cnt += 1 cnt 1 cur += w cur w if cnt <= k:
        right = mid
    else:
        left = mid cnt <= k cnt k right = mid right mid left = mid left mid print(right) print right n, k = map(int, input().split()) map(int, input().split()) n W = [int(input()) for i in range(n)] [int(input()) for i in range(n)] W right = mid mid right left = mid mid left cur = w w cur cnt += 1 1 cnt k = map(int, input().split()) map(int, input().split()) k cur += w w cur cur = 0 0 cur right = sum(W) sum(W) right mid = (left + right) // 2 (left + right) // 2 mid cnt = 1 1 cnt left = max(W)-1 max(W)-1 left
n, k = map(int, input().split())
W = [int(input()) for i in range(n)]

left = max(W)-1; right = sum(W)
while left+1 < right:
    mid = (left + right) // 2
    cnt = 1; cur = 0
    for w in W:
        if mid < cur + w:
            cur = w
            cnt += 1
        else:
            cur += w
    if cnt <= k:
        right = mid
    else:
        left = mid
print(right)