結果

問題 No.576 E869120 and Rings
ユーザー maspymaspy
提出日時 2020-05-08 23:48:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 68,008 KB
最終ジャッジ日時 2023-09-17 03:34:18
合計ジャッジ時間 15,110 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 498 ms
67,756 KB
testcase_01 AC 494 ms
67,940 KB
testcase_02 AC 507 ms
67,872 KB
testcase_03 AC 489 ms
67,988 KB
testcase_04 AC 507 ms
67,724 KB
testcase_05 AC 518 ms
67,896 KB
testcase_06 AC 507 ms
67,772 KB
testcase_07 AC 504 ms
68,008 KB
testcase_08 AC 493 ms
67,804 KB
testcase_09 AC 503 ms
67,860 KB
testcase_10 AC 498 ms
67,836 KB
testcase_11 AC 507 ms
67,820 KB
testcase_12 AC 507 ms
67,692 KB
testcase_13 AC 480 ms
66,900 KB
testcase_14 AC 485 ms
66,864 KB
testcase_15 AC 368 ms
60,836 KB
testcase_16 AC 484 ms
66,736 KB
testcase_17 AC 511 ms
66,848 KB
testcase_18 AC 505 ms
67,768 KB
testcase_19 AC 492 ms
67,888 KB
testcase_20 AC 507 ms
67,988 KB
testcase_21 AC 516 ms
67,904 KB
testcase_22 AC 109 ms
29,808 KB
testcase_23 WA -
testcase_24 AC 110 ms
29,740 KB
testcase_25 AC 108 ms
29,632 KB
testcase_26 WA -
testcase_27 AC 116 ms
29,852 KB
testcase_28 AC 108 ms
29,788 KB
testcase_29 AC 109 ms
29,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = np.frombuffer(read().rstrip(), 'S1').astype(np.float64)

A = np.concatenate([A,A])

def test(A, x):
    # avg > x が可能
    A = A - x
    Acum = np.zeros(len(A) + 1, np.float64)
    Acum[1:] = np.cumsum(A)
    S = Acum[-1]
    if S > 0:
        return True
    if K <= (N // 2):
        B = np.minimum.accumulate(Acum)
        x = np.max(Acum[K:] - B[:-K])
        return x > 0
    B = np.maximum.accumulate(Acum)
    x = np.min(Acum[K:] - B[:-K])
    return S/2 - x > 0

vals = [0, 1]
for _ in range(22):
    x = sum(vals) / 2
    vals[1-test(A, x)] = x

print(vals[0])
0