結果
問題 |
No.1211 円環はお断り
|
ユーザー |
![]() |
提出日時 | 2025-06-12 17:10:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,179 bytes |
コンパイル時間 | 161 ms |
コンパイル使用メモリ | 83,036 KB |
実行使用メモリ | 91,768 KB |
最終ジャッジ日時 | 2025-06-12 17:10:25 |
合計ジャッジ時間 | 4,560 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 13 TLE * 1 -- * 27 |
ソースコード
import sys def max_min_value(): N, K = map(int, sys.stdin.readline().split()) A = list(map(int, sys.stdin.readline().split())) total = sum(A) if K == 0: print(0) return if K == 1: print(total) return if K > N: print(0) return left = 0 right = total // K + 1 best = 0 B = A + A prefix = [0] * (len(B) + 1) for i in range(len(B)): prefix[i+1] = prefix[i] + B[i] def is_possible(M): if M * K > total: return False for i in range(N): current_sum = 0 count = 0 for j in range(i, i + N): current_sum += B[j] if current_sum >= M: count += 1 current_sum = 0 if count == K: return True if current_sum == 0 and count >= K: return True return False while left <= right: mid = (left + right) // 2 if is_possible(mid): best = mid left = mid + 1 else: right = mid - 1 print(best) max_min_value()