結果
| 問題 |
No.576 E869120 and Rings
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:31:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,628 bytes |
| コンパイル時間 | 213 ms |
| コンパイル使用メモリ | 82,604 KB |
| 実行使用メモリ | 282,816 KB |
| 最終ジャッジ日時 | 2025-06-12 15:32:54 |
| 合計ジャッジ時間 | 6,064 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | MLE * 1 -- * 26 |
ソースコード
import sys
from collections import deque
def main():
n, k = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().strip()))
duplicated = a + a # Create the duplicated array
def check(m):
# Compute the transformed array
b = [x - m for x in duplicated]
prefix = [0.0] * (2 * n + 1)
for i in range(2 * n):
prefix[i+1] = prefix[i] + b[i]
dq = deque()
for j in range(2 * n):
if j < k:
continue
start = max(0, j - n)
end = j - k
if start > end:
continue
# Remove indices from the front that are out of the start range
while dq and dq[0] < start:
dq.popleft()
# Check if current j can form a valid window
if dq:
min_prefix = prefix[dq[0]]
if prefix[j] - min_prefix >= 0:
return True
# Add the current end index to the deque
current_i = end
# Maintain deque in increasing order of prefix[i]
while dq and prefix[current_i] <= prefix[dq[-1]]:
dq.pop()
dq.append(current_i)
return False
# Binary search
low = 0.0
high = 1.0
for _ in range(100):
mid = (low + high) / 2
if check(mid):
low = mid
else:
high = mid
# Output with sufficient precision
print("{0:.11f}".format(low))
if __name__ == "__main__":
main()
gew1fw