結果
| 問題 | No.1211 円環はお断り |
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:43:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,131 bytes |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 82,440 KB |
| 実行使用メモリ | 90,832 KB |
| 最終ジャッジ日時 | 2025-06-12 21:48:08 |
| 合計ジャッジ時間 | 4,985 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | AC * 13 TLE * 1 -- * 27 |
ソースコード
import sys
def main():
N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
if K == 0:
print(0)
return
total = sum(A)
if K == 1:
print(total)
return
low = 0
high = total
best = 0
B = A + A
while low <= high:
mid = (low + high) // 2
if mid == 0:
best = max(best, 0)
low = mid + 1
continue
if total < K * mid:
high = mid - 1
continue
found = False
for i in range(N):
current = 0
count = 0
j = i
while j < i + N:
current += B[j]
if current >= mid:
count += 1
current = 0
if count >= K:
break
j += 1
if count >= K:
found = True
break
if found:
best = mid
low = mid + 1
else:
high = mid - 1
print(best)
if __name__ == "__main__":
main()
gew1fw