結果

問題 No.1211 円環はお断り
ユーザー gew1fw
提出日時 2025-06-12 19:14:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 90,768 KB
最終ジャッジ日時 2025-06-12 19:14:50
合計ジャッジ時間 4,563 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
A = list(map(int, input().split()))

def check(M):
    if M == 0:
        return True
    sum_total = sum(A)
    if sum_total < k * M:
        return False
    current_sum = 0
    count = 0
    for num in A:
        current_sum += num
        if current_sum >= M:
            count += 1
            current_sum = 0
            if count >= k:
                return True
    return count >= k

sum_total = sum(A)
low = 0
high = sum_total // k
ans = 0

while low <= high:
    mid = (low + high) // 2
    if check(mid):
        ans = mid
        low = mid + 1
    else:
        high = mid - 1

print(ans)
0