Description
Your Karate Club challenged another karate club in Your town. Each club enters N players to the match, and each player plays one game against a player from the other team. Each of the game is won are worth 2 points, and each of the game is drawn are worth 1 point. Your goal is to score as many points as possible.
Your secret agents has determined the skill of the every member of the opposing team, and of course you know the skill of Eve RY member of your own team. Information to decide which opposing player would play against each of the your players in order to maximize Y Our score. Assume that the player with the higher skill in a game would always win, and if the players has the same skill then they w Ill draw.
You'll be given the skills of your players and of the opposing players, you have to find the maximum number of points th At your team can score.
Input
Input starts with an integer T (≤70), denoting the number of test cases.
Each case is starts with a line containing an integer N (1≤n≤50). The next line contains N space separated integers denoting the skills of the players team. The next line also contains N space separated integers denoting the skills of the players team. Each of the skills lies in the range [1, +].
Output
For each case, print the case number and the maximum number of points your team can score.
Sample Input
4
2
6 U
6 2
2
6 2
6 U
3
5 10 1
5 10 1
4
10 7 1 4
15 3 8 7
Sample Output
Case 1:4
Case 2:2
Case 3:4
Case 4:5
With the fastest horse with each other the fastest ponies, if faster than the other side of the horse, first win a, otherwise the slowest horse and the other side of the slowest horse, if faster than the other side of the horse, and then win another, otherwise if the slowest horse and the other side of the fastest horse, if the fastest horse than the other side, win a.
1#include <cstdio>2#include <algorithm>3#include <string.h>4 using namespacestd;5 intMain ()6 {7 intt,n,sum,a[1010],b[1010],key[1010],k,j,i,s,num;8scanf"%d",&t);9num=0;Ten while(t--) One { Ascanf"%d",&n); - for(i =0; i<n;i++) - { thescanf"%d",&a[i]); - } - for(i=0; i<n;i++) - { +scanf"%d",&b[i]); - } +sum=0; ASort (a,a+n); atSort (b,b+n); -k=n-1; -s=0; -j=0; - for(i=n-1; i>=j;i--) - { in if(A[i] >B[k]) - { tosum+=2; +k--; - } the Else if(A[i] <B[k]) * { $k--;Panax NotoginsengJ + +; -i++; the } + A Else the { + if(A[j] >B[s]) - { $sum+=2; $J + +; -s++; -i++; the } - ElseWuyi { the if(A[j] = =B[k]) - { Wusum++; -J + +; Aboutk--; $i++; - } - Else - { AJ + +; +k--; thei++; - } $ } the the the } the } -printf"Case %d:%d\n",++num,sum); in } the}
Henan Multi-school freshman training tournament (similar to Tian Bogey horse racing)