結果

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

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    N = int(data[0])
    K = int(data[1])
    A = list(map(int, data[2:2 + N]))
    
    total = sum(A)
    low = 0
    high = total
    
    def is_possible(M):
        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 and current_sum >= M
    
    while low < high:
        mid = (low + high + 1) // 2
        if is_possible(mid):
            low = mid
        else:
            high = mid - 1
    print(low)

if __name__ == "__main__":
    main()
0