結果
| 問題 |
No.1211 円環はお断り
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:32:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 919 bytes |
| コンパイル時間 | 139 ms |
| コンパイル使用メモリ | 82,248 KB |
| 実行使用メモリ | 96,404 KB |
| 最終ジャッジ日時 | 2025-03-31 17:33:08 |
| 合計ジャッジ時間 | 4,449 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 WA * 5 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
N = int(input[0])
K = int(input[1])
A = list(map(int, input[2:2+N]))
total = sum(A)
if K == 0:
print(0)
return
left = 1
right = total // K
if right < 1:
print(0)
return
def is_possible(M):
if M == 0:
return False
cnt = 0
current = 0
for num in A:
current += num
if current >= M:
cnt += 1
current = 0
return cnt >= K
answer = 0
while left <= right:
mid = (left + right + 1) // 2
if mid * K > total:
right = mid - 1
continue
if is_possible(mid):
answer = mid
left = mid + 1
else:
right = mid - 1
print(answer)
if __name__ == '__main__':
main()
lam6er