| IPL 2026 |
|---|
| Finished |
Auchenai is playing a long series of $$$n$$$ Riichi Mahjong games. After each game, he receives a positive performance feedback score from the MAKA AI and records his placement tier.
For the $$$i$$$-th game, let $$$a_i$$$ be MAKA's feedback score and $$$b_i\in \{1, 2\}$$$ be Auchenai's placement tier. A subsequence of games is called calm if the placement tiers are nondecreasing.
Given an integer $$$K$$$, Auchenai wants to know the maximum length $$$L$$$ of a calm subsequence whose average MAKA score is at least $$$K$$$. That is, the maximum $$$L$$$ such that there exists a sequence $$$1\le i_1\le i_2\le\ldots \le i_L\le n$$$ satisfying $$$b_{i_1} \leq b_{i_2}\le \ldots \leq b_{i_L}$$$ and $$$$$$\frac{a_{i_1} + a_{i_2}+\cdots + a_{i_L}}{L}\geq K.$$$$$$
If no such subsequence exists, output $$$0$$$.
The first line contains two integers $$$n$$$ and $$$K$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$, $$$1 \leq K \leq 10^9$$$) — the number of games and the desired average MAKA score.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots , a_n$$$ ($$$1 \leq a_i \leq 10^9$$$) — the MAKA scores.
The third line contains $$$n$$$ integers $$$b_1, b_2, \ldots , b_n$$$ ($$$b_i\in \{1, 2\}$$$) — the placement tiers.
Output a single integer — the maximum length $$$L$$$ of a calm subsequence with average MAKA score at least $$$K$$$.
5 45 4 6 4 31 1 2 2 2
5
8 69 2 8 7 1 2 10 61 2 1 2 1 1 2 2
6
8 83 9 3 9 3 9 3 91 2 1 2 1 2 1 2
4
| Name |
|---|


