結果

問題 No.1211 円環はお断り
ユーザー gew1fw
提出日時 2025-06-12 17:09:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 961 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,156 KB
実行使用メモリ 93,808 KB
最終ジャッジ日時 2025-06-12 17:09:53
合計ジャッジ時間 4,439 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other AC * 13 TLE * 1 -- * 27
権限があれば一括ダウンロードができます

ソースコード

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 = sum(A)
    low = 0
    high = total_sum
    ans = 0

    def can_split(mid):
        if mid == 0:
            return True
        if total_sum < mid * K:
            return False
        for i in range(N):
            current_sum = 0
            cnt = 0
            for j in range(N):
                pos = (i + j) % N
                current_sum += A[pos]
                if current_sum >= mid:
                    cnt += 1
                    current_sum = 0
                    if cnt >= K:
                        return True
        return False

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

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