编程介的小学生 2017-06-05 16:53 采纳率: 20.5%
浏览 786
已采纳

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

  • 写回答

3条回答 默认 最新

  • threenewbee 2017-06-06 15:57
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?