AT_abc469_e.Pro Exam Eligibility

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a string SS of length NN consisting of o and x.
It is guaranteed that SS contains at least KK occurrences of o.
Takahashi played a certain game NN times.
In the ii-th game, he won if the ii-th character of SS is o, and lost if it is x.

Takahashi chooses a pair of integers ll and rr satisfying the following conditions.

  • 1≤l≤r≤N1 \leq l \leq r \leq N
  • He won at least KK times in the games from the ll-th through the rr-th.

Find the maximum possible value of the win rate in the games from the ll-th through the rr-th.

给你一个长度为 NN 的字符串 SS,仅由字符 o 和 x 组成。
保证 SS 中至少包含 KK 个 o。
高桥共进行了 NN 次游戏。
在第 ii 次游戏中,若 SS 的第 ii 个字符为 o,则他获胜;若为 x,则失败。

高桥选择一对满足以下条件的整数 ll 和 rr:

  • 1≤l≤r≤N1 \leq l \leq r \leq N
  • 在第 ll 次至第 rr 次游戏中,他至少获胜 KK 次。

求第 ll 次至第 rr 次游戏中的最高可能胜率。

输入格式

The input is given from Standard Input in the following format:

NN KK
SS

输入从标准输入中以如下格式给出:

NN KK
SS

输出格式

Output the answer in one line. Answers with an absolute or relative error of at most 10−610^{-6} from the true answer will be accepted.

单行输出答案。与真实答案的绝对或相对误差不超过 10−610^{-6} 的答案将被接受。

输入输出样例

  • 输入#1

    10 4
    oxooxoxxox

    输出#1

    0.6666666666
  • 输入#2

    5 1
    xxoxx

    输出#2

    1
  • 输入#3

    16 10
    xxxoxooooxoxoooo

    输出#3

    0.769230769230769

说明/提示

Sample 1 Explanation:
Choosing (1,6)(1,6) as (l,r)(l,r) gives a win rate of 23\frac{2}{3}.
It is impossible to make the win rate larger than this while satisfying the conditions.

Constraints

  • 1≤K≤N≤1061 \leq K \leq N \leq 10^6
  • NN and KK are integers.
  • SS is a string of length NN consisting of o and x.
  • SS contains at least KK occurrences of o.

样例 1 解释:
选择 (1,6)(1,6) 作为 (l,r)(l,r) 可得到胜率为 23\frac{2}{3}。
在满足所有条件的前提下,无法使胜率高于该值。

限制条件

  • 1≤K≤N≤1061 \leq K \leq N \leq 10^6
  • NN 和 KK 均为整数。
  • SS 是一个长度为 NN 的字符串,仅由字符 o 和 x 组成。
  • SS 中至少包含 KK 个 o。

输入解题思路,AI测评打分。不知道怎么写?

首页