#abc343f. F - Second Largest Query
F - Second Largest Query
Score: points
问题描述
你得到一个长度为 的序列 。
按照给定顺序处理 个查询。每个查询属于以下两种类型之一:
- 类型 : 以
1 p x
的形式给出。将 的值更改为 。 - 类型 : 以
2 l r
的形式给出。打印子序列 中第二大值的 出现次数。具体来说,输出满足条件 的整数 的个数,使得在 中恰好有一个不同于 的更大值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a sequence of length .
Process queries in the order they are given. Each query is of one of the following two types:
- Type : Given in the form
1 p x
. Change the value of to . - Type : Given in the form
2 l r
. print the number of occurrences of the second largest value in . More precisely, print the number of integers satisfying such that there is exactly one distinct value greater than among .
Constraints
- For type- queries, .
- For type- queries, .
- For type- queries, .
- There is at least one type- query.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Here, is the -th query and given in one of the following formats:
Output
Let be the number of type- queries. Print lines. The -th line should contain the response to the -th type- query.
Sample Input 1
5 4
3 3 1 4 5
2 1 3
2 5 5
1 3 3
2 2 4
Sample Output 1
1
0
2
Initially, .
For the first query, the second largest value in is , which appears once in , so print .
For the second query, there is no second largest value in , so print .
The third query makes .
For the fourth query, the second largest value in , is , which appears twice in , so print .
Sample Input 2
1 1
1000000000
2 1 1
Sample Output 2
0
Sample Input 3
8 9
2 4 4 3 9 1 1 2
1 5 4
2 7 7
2 2 6
1 4 4
2 2 5
2 2 7
1 1 1
1 8 1
2 1 8
Sample Output 3
0
1
0
2
4
update @ 2024/3/10 01:17:00