結果

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

ソースコード

diff #

n, k = map(int, input().split())
a = list(map(int, input().split()))
total = sum(a)

left = 1
right = total // k
answer = 0

while left <= right:
    mid = (left + right) // 2
    if total < k * mid:
        right = mid - 1
        continue
    current_sum = 0
    count = 0
    for num in a:
        current_sum += num
        if current_sum >= mid:
            count += 1
            current_sum = 0
            if count >= k:
                break
    if count >= k:
        answer = mid
        left = mid + 1
    else:
        right = mid - 1

print(answer)
0