310655: CF1866F. Freak Joker Process

Memory Limit:1024 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Freak Joker Processtime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

After the success of the basketball teams formed and trained by Pak Chanek last year (Basketball Together), Pak Chanek wants to measure the performance of each player that is considered as a superstar.

There are $N$ superstar players that have been trained by Pak Chanek. At the end of the season, some calculations will be made on the performance of the $N$ players using an international method. Each player has two values $A_i$ and $B_i$ where each represents the offensive and defensive value of that player.

Define $\text{RankA}(i)$ as the offensive ranking of the $i$-th player, whose value is $c+1$ with $c$ here representing the number of $j$ ($1 \leq j \leq N$) such that $A_j>A_i$. Define $\text{RankB}(i)$ as the defensive ranking of the $i$-th player, whose value is $c+1$ with $c$ here representing the number of $j$ ($1 \leq j \leq N$) such that $B_j>B_i$.

Define $\text{RankOverall}(i)$ as the overall ranking of the $i$-th player, whose value is $c+1$ with $c$ here representing the number of $j$ ($1 \leq j \leq N$) such that $\text{RankA}(j)+\text{RankB}(j)<\text{RankA}(i)+\text{RankB}(i)$.

During the next $Q$ days, exactly one event will happen on each day. Each event is one of the three following possibilities:

  • 1 k c – If $c$ is +, then $A_k$ increases by $1$. If $c$ is -, then $A_k$ decreases by $1$. ($1\leq k\leq N$; $c$ is + or -)
  • 2 k c – If $c$ is +, then $B_k$ increases by $1$. If $c$ is -, then $B_k$ decreases by $1$. ($1\leq k\leq N$; $c$ is + or -)
  • 3 k – Pak Chanek wants to know the value of $\text{RankOverall}(k)$ at that moment. ($1\leq k\leq N$)
Input

The first line contains a single integer $N$ ($1\leq N\leq10^5$) — the number of superstar players.

The second line contains $N$ integers $A_1, A_2, A_3 \ldots, A_N$ ($1 \leq A_i \leq 10^5$) — the offensive value of each player.

The third line contains $N$ integers $B_1, B_2, B_3 \ldots, B_N$ ($1 \leq B_i \leq 10^5$) — the defensive value of each player.

The fourth line contains a single integer $Q$ ($1\leq Q\leq10^5$) — the number of events.

The $j$-th of the next $Q$ lines contains the $j$-th event as described. At any moment, each value of $A_i$ and $B_i$ is always between $1$ and $10^5$ inclusive. There is at least one event of type $3$.

Output

For each event of type $3$, output a line containing an integer representing the value of $\text{RankOverall}(k)$ at that moment.

ExampleInput
5
3 3 1 3 2
3 7 1 3 1
8
3 1
3 2
2 4 +
1 2 -
3 2
3 3
2 2 -
3 1
Output
2
1
2
5
2
Note

At the $8$-th event, $A=[3,2,1,3,2]$ and $B=[3,6,1,4,1]$. It can be obtained that the values of $\text{RankA}$ and $\text{RankB}$ for each player are as follows:

  • $\text{RankA}(1)=1$, $\text{RankB}(1)=3$
  • $\text{RankA}(2)=3$, $\text{RankB}(2)=1$
  • $\text{RankA}(3)=5$, $\text{RankB}(3)=4$
  • $\text{RankA}(4)=1$, $\text{RankB}(4)=2$
  • $\text{RankA}(5)=3$, $\text{RankB}(5)=4$

So it can be obtained that $\text{RankOverall}(1)=2$.

Output

**题目大意:**

在上一季篮球比赛成功之后,Pak Chanek想要衡量被他训练的每位超级巨星的表现。有N位超级巨星球员被Pak Chanek训练。在赛季结束时,将使用一种国际方法对N位球员的表现进行一些计算。每位球员有两个值$A_i$和$B_i$,分别代表该球员的进攻和防守价值。

定义$\text{RankA}(i)$为第$i$位球员的进攻排名,其值是$c+1$,这里的$c$代表满足$A_j > A_i$的$j$的数量($1 \leq j \leq N$)。定义$\text{RankB}(i)$为第$i$位球员的防守排名,其值是$c+1$,这里的$c$代表满足$B_j > B_i$的$j$的数量($1 \leq j \leq N$)。

定义$\text{RankOverall}(i)$为第$i$位球员的综合排名,其值是$c+1$,这里的$c$代表满足$\text{RankA}(j) + \text{RankB}(j) < \text{RankA}(i) + \text{RankB}(i)$的$j$的数量($1 \leq j \leq N$)。

在接下来的$Q$天里,每天会发生一个事件。每个事件是以下三种可能性之一:

1. `1 k c` – 如果$c$是`+`,那么$A_k$增加1。如果$c$是`-`,那么$A_k$减少1。($1 \leq k \leq N$;$c$是`+`或`-`)
2. `2 k c` – 如果$c$是`+`,那么$B_k$增加1。如果$c$是`-`,那么$B_k$减少1。($1 \leq k \leq N$;$c$是`+`或`-`)
3. `3 k` – Pak Chanek想要知道那一刻$\text{RankOverall}(k)$的值。($1 \leq k \leq N$)

**输入输出数据格式:**

**输入:**

- 第一行包含一个整数$N$($1 \leq N \leq 10^5$)——超级巨星球员的数量。
- 第二行包含$N$个整数$A_1, A_2, A_3 \ldots, A_N$($1 \leq A_i \leq 10^5$)——每个球员的进攻值。
- 第三行包含$N$个整数$B_1, B_2, B_3 \ldots, B_N$($1 \leq B_i \leq 10^5$)——每个球员的防守值。
- 第四行包含一个整数$Q$($1 \leq Q \leq 10^5$)——事件的数量。
- 接下来的$Q$行中的第$j$行包含第$j$个事件的描述。在任何时刻,$A_i$和$B_i$的值总是在$1$和$10^5$之间(包括$1$和$10^5$)。至少有一个类型为$3$的事件。

**输出:**

- 对于每个类型为$3$的事件,输出一行,包含一个整数,代表那一刻$\text{RankOverall}(k)$的值。**题目大意:** 在上一季篮球比赛成功之后,Pak Chanek想要衡量被他训练的每位超级巨星的表现。有N位超级巨星球员被Pak Chanek训练。在赛季结束时,将使用一种国际方法对N位球员的表现进行一些计算。每位球员有两个值$A_i$和$B_i$,分别代表该球员的进攻和防守价值。 定义$\text{RankA}(i)$为第$i$位球员的进攻排名,其值是$c+1$,这里的$c$代表满足$A_j > A_i$的$j$的数量($1 \leq j \leq N$)。定义$\text{RankB}(i)$为第$i$位球员的防守排名,其值是$c+1$,这里的$c$代表满足$B_j > B_i$的$j$的数量($1 \leq j \leq N$)。 定义$\text{RankOverall}(i)$为第$i$位球员的综合排名,其值是$c+1$,这里的$c$代表满足$\text{RankA}(j) + \text{RankB}(j) < \text{RankA}(i) + \text{RankB}(i)$的$j$的数量($1 \leq j \leq N$)。 在接下来的$Q$天里,每天会发生一个事件。每个事件是以下三种可能性之一: 1. `1 k c` – 如果$c$是`+`,那么$A_k$增加1。如果$c$是`-`,那么$A_k$减少1。($1 \leq k \leq N$;$c$是`+`或`-`) 2. `2 k c` – 如果$c$是`+`,那么$B_k$增加1。如果$c$是`-`,那么$B_k$减少1。($1 \leq k \leq N$;$c$是`+`或`-`) 3. `3 k` – Pak Chanek想要知道那一刻$\text{RankOverall}(k)$的值。($1 \leq k \leq N$) **输入输出数据格式:** **输入:** - 第一行包含一个整数$N$($1 \leq N \leq 10^5$)——超级巨星球员的数量。 - 第二行包含$N$个整数$A_1, A_2, A_3 \ldots, A_N$($1 \leq A_i \leq 10^5$)——每个球员的进攻值。 - 第三行包含$N$个整数$B_1, B_2, B_3 \ldots, B_N$($1 \leq B_i \leq 10^5$)——每个球员的防守值。 - 第四行包含一个整数$Q$($1 \leq Q \leq 10^5$)——事件的数量。 - 接下来的$Q$行中的第$j$行包含第$j$个事件的描述。在任何时刻,$A_i$和$B_i$的值总是在$1$和$10^5$之间(包括$1$和$10^5$)。至少有一个类型为$3$的事件。 **输出:** - 对于每个类型为$3$的事件,输出一行,包含一个整数,代表那一刻$\text{RankOverall}(k)$的值。

加入题单

上一题 下一题 算法标签: