CF1776H.Beppa and SwerChat
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Beppa and her circle of geek friends keep up to date on a group chat in the instant messaging app SwerChat TM .
The group has n members, excluding Beppa. Each of those members has a unique ID between 1 and n . When a user opens a group chat, SwerChat TM displays the list of other members of that group, sorted by decreasing times of last seen online (so the member who opened the chat most recently is the first of the list). However, the times of last seen are not displayed.
Today, Beppa has been busy all day: she has only opened the group chat twice, once at 9:00 and once at 22:00. Both times, she wrote down the list of members in the order they appeared at that time. Now she wonders: what is the minimum number of other members that must have been online at least once between 9:00 and 22:00?
Beppa is sure that no two members are ever online at the same time and no members are online when Beppa opens the group chat at 9:00 and 22:00.
输入格式
Each test contains multiple test cases. The first line contains an integer t ( 1≤t≤10000 ) — the number of test cases. The descriptions of the t test cases follow.
The first line of each test case contains an integer n ( 1≤n≤105 ) — the number of members of the group excluding Beppa.
The second line contains n integers a1,a2,…,an ( 1≤ai≤n ) — the list of IDs of the members, sorted by decreasing times of last seen online at 9:00.
The third line contains n integers b1,b2,…,bn ( 1≤bi≤n ) — the list of IDs of the members, sorted by decreasing times of last seen online at 22:00.
For all 1≤i<j≤n , it is guaranteed that ai=aj and bi=bj .
It is also guaranteed that the sum of the values of n over all test cases does not exceed 105 .
输出格式
For each test case, print the minimum number of members that must have been online between 9:00 and 22:00.
输入输出样例
输入#1
4 5 1 4 2 5 3 4 5 1 2 3 6 1 2 3 4 5 6 1 2 3 4 5 6 8 8 2 4 7 1 6 5 3 5 6 1 4 8 2 7 3 1 1 1
输出#1
2 0 4 0
说明/提示
In the first test case, members 4,5 must have been online between 9:00 and 22:00.
In the second test case, it is possible that nobody has been online between 9:00 and 22:00.