http://www.lydsy.com:808/JudgeOnline/problem.php?id=1034
I would say that this is the revision of the POJ Tianji the horse racing ...
But the game rules of this topic slightly different, won 2 points, flat 1 points, lose no points, so greedy process and poj the problem slightly different, specific look at the code bar.
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include < Algorithm> #define MAXN 100050using namespace Std;int a[maxn],b[maxn],n;int cal ()//Note: The value of the CAL function is a-party score, The result is the highest case of a-side { int minpa=1,minpb=1,maxpa=n,maxpb=n,ans=0;//a minimum pointer, B's minimum pointer, A's maximum pointer, B's maximum pointer while (minpa< =MAXPA) { if (A[MINPA]>B[MINPB]) ans+=2,minpa++,minpb++,//a minimum is greater than B, with the smallest else if of A and B (a[maxpa]>b [MAXPB]) Ans+=2,maxpa--, maxpb--; A maximum greater than B max else ans+= (A[MINPA]==B[MAXPB]), minpa++,maxpb--;//otherwise a min and B max ratio } return ans; int main () { scanf ("%d", &n); for (int i=1;i<=n;i++) scanf ("%d", &a[i]); for (int i=1;i<=n;i++) scanf ("%d", &b[i]); Sort (a+1,a+n+1); Sort (b+1,b+n+1); printf ("%d", Cal ()); Swap (A, b); printf ("%d\n", 2*n-cal ()); return 0;}
[Bzoj 1034][zjoi2008] Bubble Hall BNB (class Tian bogey horse racing greed)