結果
問題 | No.1211 円環はお断り |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:55:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 864 bytes |
コンパイル時間 | 235 ms |
コンパイル使用メモリ | 82,180 KB |
実行使用メモリ | 96,204 KB |
最終ジャッジ日時 | 2025-03-26 15:56:17 |
合計ジャッジ時間 | 5,164 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 WA * 9 |
ソースコード
def main():import sysinput = sys.stdin.read().split()N = int(input[0])K = int(input[1])A = list(map(int, input[2:2+N]))total = sum(A)max_A = max(A)if K == 1:print(total)returnleft = 1right = min(total // K, max_A)answer = 0def is_possible(M):if total < K * M:return Falsecnt = 0current = 0for num in A:current += numif current >= M:cnt += 1current = 0return cnt >= K or (cnt >= K-1 and current >= M)while left <= right:mid = (left + right) // 2if is_possible(mid):answer = midleft = mid + 1else:right = mid - 1print(answer)if __name__ == "__main__":main()