CF1866F.Freak Joker Process
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 Ai and Bi where each represents the offensive and defensive value of that player.
Define 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≤j≤N ) such that Aj>Ai . Define 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≤j≤N ) such that Bj>Bi .
Define 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≤j≤N ) such that RankA(j)+RankB(j)<RankA(i)+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 Ak increases by 1 . If c is -, then Ak decreases by 1 . ( 1≤k≤N ; c is + or -)
- 2 k c – If c is +, then Bk increases by 1 . If c is -, then Bk decreases by 1 . ( 1≤k≤N ; c is + or -)
- 3 k – Pak Chanek wants to know the value of RankOverall(k) at that moment. ( 1≤k≤N )
输入格式
The first line contains a single integer N ( 1≤N≤105 ) — the number of superstar players.
The second line contains N integers A1,A2,A3…,AN ( 1≤Ai≤105 ) — the offensive value of each player.
The third line contains N integers B1,B2,B3…,BN ( 1≤Bi≤105 ) — the defensive value of each player.
The fourth line contains a single integer Q ( 1≤Q≤105 ) — 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 Ai and Bi is always between 1 and 105 inclusive. There is at least one event of type 3 .
输出格式
For each event of type 3 , output a line containing an integer representing the value of RankOverall(k) at that moment.
输入输出样例
输入#1
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
输出#1
2 1 2 5 2
说明/提示
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 RankA and RankB for each player are as follows:
- RankA(1)=1 , RankB(1)=3
- RankA(2)=3 , RankB(2)=1
- RankA(3)=5 , RankB(3)=4
- RankA(4)=1 , RankB(4)=2
- RankA(5)=3 , RankB(5)=4
So it can be obtained that RankOverall(1)=2 .