#include <cstdio>#include<cstring>#include<iostream>#include<queue>#include<stack>#include<cmath>#include<map>#include<algorithm>using namespaceStd;map<string,string>Mp;vector<vector<int> >G;Const intinf=0x3f3f3f3f;Const intmaxn=1100;intA[MAXN], B[MAXN];intN, M;intMain () {intT, cas=1; scanf ("%d", &T); while(t--) {scanf ("%d", &N); for(intI=1; i<=n; i++) scanf ("%d", &A[i]); for(intI=1; i<=n; i++) scanf ("%d", &B[i]); Sort (a+1, a+n+1); Sort (b+1, b+n+1); intLA, LB, RA, rb, ans; Ans=0; La=lb=1; RA=rb=N; for(intI=1; i<=n; i++) { if(A[ra] >B[RB]) {ans+=2; RA--; RB--; } Else if(A[ra] <B[RB]) {La++; RB--; } Else if(A[la] >b[lb]) {ans+=2; La++; LB++; } Else { if(a[la]==B[rb]) ans++; La++; RB--; }} printf ("Case %d:%d\n", cas++, ans); } return 0;}
View Code
Light OJ---1198
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
4 7
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
Tian Bogey horse racing---karate club