AT_abc469_e.Pro Exam Eligibility
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a string S of length N consisting of o and x.
It is guaranteed that S contains at least K occurrences of o.
Takahashi played a certain game N times.
In the i-th game, he won if the i-th character of S is o, and lost if it is x.
Takahashi chooses a pair of integers l and r satisfying the following conditions.
- 1≤l≤r≤N
- He won at least K times in the games from the l-th through the r-th.
Find the maximum possible value of the win rate in the games from the l-th through the r-th.
给你一个长度为 N 的字符串 S,仅由字符 o 和 x 组成。
保证 S 中至少包含 K 个 o。
高桥共进行了 N 次游戏。
在第 i 次游戏中,若 S 的第 i 个字符为 o,则他获胜;若为 x,则失败。
高桥选择一对满足以下条件的整数 l 和 r:
- 1≤l≤r≤N
- 在第 l 次至第 r 次游戏中,他至少获胜 K 次。
求第 l 次至第 r 次游戏中的最高可能胜率。
输入格式
The input is given from Standard Input in the following format:
N K
S
输入从标准输入中以如下格式给出:
N K
S
输出格式
Output the answer in one line. Answers with an absolute or relative error of at most 10−6 from the true answer will be accepted.
单行输出答案。与真实答案的绝对或相对误差不超过 10−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) as (l,r) gives a win rate of 32.
It is impossible to make the win rate larger than this while satisfying the conditions.
Constraints
- 1≤K≤N≤106
- N and K are integers.
- S is a string of length N consisting of
oandx. - S contains at least K occurrences of
o.
样例 1 解释:
选择 (1,6) 作为 (l,r) 可得到胜率为 32。
在满足所有条件的前提下,无法使胜率高于该值。
限制条件
- 1≤K≤N≤106
- N 和 K 均为整数。
- S 是一个长度为 N 的字符串,仅由字符
o和x组成。 - S 中至少包含 K 个
o。
输入解题思路,AI测评打分。不知道怎么写?