编程介的小学生 2017-11-07 03:25 采纳率: 20.5%
浏览 372
已结题

Failure Is a Good Thing

Problem Description

Last week, my granddaughter started kindergarten, and, as is conventional, I wished her success. I was lying. What I actually wish for her is failure. I believe in the power of failure.

Success is boring. Success is proving that you can do something that you already know you can do, or doing something correctly the first time, which can often be a problematical victory. First-time success is usually afluke. First-time failure, by contrast, is expected; it is the natural order of things.

Failure is how we learn. I have been told of an African phrase describing a good cook as "she who has broken many pots." If you've spent enough time in the kitchen to have broken a lot of pots, probably you know a fair amount about cooking. I once had a late dinner with a group of chefs, and they spent time comparing knife wounds and burn scars. They knew how much credibility their failures gave them.

-- "Failure Is a Good Thing"

There are many kinds of failure, one of them is failing in exams. An exam has finished, and the score of each students has also been calculated. It is known that different students may get the same score.

Before the teacher telling his/her students their score, All the students are very nervous, so they get together to guess the rank of themselves in this example and the rank count backwards. Now the problem is: how many of the guesses will be correct at most?

There are n (1 ≤ n ≤ 1000) students participate in the exam, and the i-th student guesses: his/her rank is ri and is bi count backwards. (1 ≤ ri, bi ≤ n), different students may guess the same. A student's rank is r means that there are r-1 students's score is higher than him/her and the concept is similar when counts backwards.

Input
The first line of the input file contains a signle integer: T (1 ≤ T ≤ 10), representing the number of test cases. For each test case, the first line contains a integer n, the second line has n integers: r1, r2, ..., rn and in the third line there are n integers: b1, b2, ..., bn.

Output
For each test case, output the answer.

Sample Input
1
3
3 1 3
1 3 3

Sample Output
2

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?