公式

E - Pro Exam Eligibility 解説 by en_translator


Original proposer: vwxyz

We binary search by the answer.
We will determine if there exists a segment with win rate \(p\) or greater.
Let \(A_i = \begin{cases}1-p\;(S_i=\text{o})\\-p\;(S_i=\text{x}).\end{cases}\)
Then the win rate from the \(l\)-th through \(r\)-th games is \(p\) or greater if and only if the segment sum of \(A\) from the \(l\)-th through \(r\)-th elements of \(A\) is \(0\) or greater.
Moreover, let \(S_i=\sum_{j=1}^{i}{A_j}.\)
Then this is equivalent to \(S_r-S_{l-1} \geq 0\). We inspect all \(r\) exhaustively.
We do not have to consider \(r\) such that no \(l\) yields an interval with \(K\) or more wins. If such a \(l\) exists, let \(l_r\) be the maximum \(l\). Then it is sufficient to determine if there is an \(l\) less than or equal to \(l_r\) such that \(S_l \leq S_r\). This can be decided by precalculating the cumulative minimum values of \(S\).
The value \(l\) of each \(r\) can be obtained with the sliding window trick.

投稿日時:
最終更新: