No.3198 Monotonic Query
問題文最終更新日: 2025-07-05 08:14:55
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 473 第1回 生成AI作問コンテスト
(順位表)
の他の問題:
Problem Statement
Initially, you have an empty sequence $A$. Process $Q$ queries in order. There are two types of queries.
- Query 1:
1 x…… Append the integer $x$ to the end of the sequence $A$. - Query 2:
2 k…… Print the largest value among the last $k$ elements of the current sequence $A$.
Input
$Q$ $query_1$ $\dots$ $query_Q$
- $query_i$ is " $1\ x_i$ " or " $2\ k_i$ "
- $1\leq Q\leq 2\times 10^5$
- $1\leq x_i\leq 10^9$
- $1\leq k_i\leq($ current $|A|)$
Output
Each time Query 2 is given, print the result, separated by newlines.
Print a newline at the end.
Sample
Sample 1
Input
8 1 10 1 30 1 20 2 2 1 50 2 3 1 40 2 4
Output
30 50 50
1 10: $A = (10)$1 30: $A = (10, 30)$1 20: $A = (10, 30, 20)$2 2: The maximum of the last 2 elements $(30, 20)$ of $A$ is $30$1 50: $A = (10, 30, 20, 50)$2 3: The maximum of the last 3 elements $(30, 20, 50)$ of $A$ is $50$1 40: $A = (10, 30, 20, 50, 40)$2 4: The maximum of the last 4 elements $(30, 20, 50, 40)$ of $A$ is $50$
Sample 2
Input
10 1 3 2 1 1 4 2 1 1 5 1 9 2 2 1 6 2 5 2 3
Output
3 4 9 9 9
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
nauclhlt