結果
| 問題 | No.1211 円環はお断り | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 15:40:23 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 797 bytes | 
| コンパイル時間 | 257 ms | 
| コンパイル使用メモリ | 82,444 KB | 
| 実行使用メモリ | 96,752 KB | 
| 最終ジャッジ日時 | 2025-06-12 15:40:28 | 
| 合計ジャッジ時間 | 4,528 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 36 WA * 5 | 
ソースコード
def max_min_sum():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    K = int(input[idx])
    idx += 1
    A = list(map(int, input[idx:idx+N]))
    sum_A = sum(A)
    
    low = 0
    high = sum_A
    best = 0
    
    def is_possible(M):
        count = 0
        current_sum = 0
        for num in A:
            current_sum += num
            if current_sum >= M:
                count += 1
                current_sum = 0
                if count >= K:
                    break
        return count >= K and current_sum == 0
    
    while low <= high:
        mid = (low + high) // 2
        if is_possible(mid):
            best = mid
            low = mid + 1
        else:
            high = mid - 1
    print(best)
    
max_min_sum()
            
            
            
        