問題一覧 > 通常問題

No.3198 Monotonic Query

レベル : / AI推定難易度 : 700 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 139
作問者 : YY-otter / テスター : nauclhlt
お気に入りにしたユーザー ProblemId : 12431 / 自分の提出
問題文最終更新日: 2025-07-05 08:14:55
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$.
It is guaranteed that whenever Query 2 ( $2\ k$ ) is given, the current sequence $A$ has at least $k$ elements.

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. 1 10: $A = (10)$
  2. 1 30: $A = (10, 30)$
  3. 1 20: $A = (10, 30, 20)$
  4. 2 2: The maximum of the last 2 elements $(30, 20)$ of $A$ is $30$
  5. 1 50: $A = (10, 30, 20, 50)$
  6. 2 3: The maximum of the last 3 elements $(30, 20, 50)$ of $A$ is $50$
  7. 1 40: $A = (10, 30, 20, 50, 40)$
  8. 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もしくは右上の雲マークをクリックしてアカウントを作成してください。