[ZJOI2008] Bubble Hall BNB
Time Limit:1 Sec
Memory limit:256 MB
Topic Connection http://www.lydsy.com/JudgeOnline/problem.php?id=1034
Description
During the Noi period, in order to strengthen the exchanges between the provincial athletes, the organizing committee decided to organize an inter-provincial e-sports competition, each province's team by the N players, the competition is the project is suitable for all ages network game Bubble Hall. Before each competition, the coaches of the two sides submit a list of contestants to the organizing committee, which determines the order of the players to play, and shall not be modified once determined. In the competition, a contestant of the two sides, contestant No. Second ..., the N player catches the fight, and plays N games altogether. Each win a match 2 points, the level of 1 points, lose a score. Finally, the two sides of the single-field score summed up the total score, the high score of the team to advance (the same total score decision). As the leader of Zhejiang team, you have already understood the bubble hall level of all the players in the province beforehand and measured it with a strength value. To simplify the problem, we assume that players in the game are completely unaffected by any external factors, that is, strong players will be able to overcome the weak players, and two players of the same strength must fight flat. Since we have no idea what strategy the opponent will use to determine the order of appearances, all teams have adopted a strategy of completely randomly determining the order of appearances. Of course you don't want to play the game in such a shady way. You want to know in advance how many points the Zhejiang team will get in the best and worst case scenario.
Input
The first behavior of the input is an integer n, representing the number of each team. The next n rows, an integer per line, describe the strength of the players in the N-bit Zhejiang team. The next n lines, an integer per line, describe the strength of your opponent's N-players. 20% of the data in,1<=n<=10; 40%,1<=n<=100; 60% of the data in,1<=n<=1000; 100% of the data, 1<=n<= 100000, and the strength of all players is between 0 and 10000000.
Output
including two spaces separated by a number of integers, respectively, the Zhejiang team in the best and worst case, respectively, how many points can be. Do not output extra white space characters at the end of a row.
Sample Input
2
1
3
2
4
Sample Output
2 0HINT
Test instructions
Exercises
Tian Bogey horse racing, greedy to engage in ~
Code:
//Qscqesze#include <cstdio>#include<cmath>#include<cstring>#include<ctime>#include<iostream>#include<algorithm>#include<Set>#include<bitset>#include<vector>#include<sstream>#include<queue>#include<typeinfo>#include<fstream>#include<map>#include<stack>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineMAXN 200500#defineMoD 1001#defineEPS 1e-9#definePi 3.1415926intNum;//const int INF=0X7FFFFFFF;Constll inf=999999999; inline ll read () {ll x=0, f=1;CharCh=GetChar (); while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//*************************************************************************************intA[MAXN];intB[MAXN];intN;intsolve () {intans=0, mina=1, minb=1, maxa=n,maxb=N; while(mina<=Maxa) { if(A[mina]>b[minb]) ans+=2, mina++,minb++; Else if(A[MAXA]>B[MAXB]) ans+=2, Maxa--, maxb--; Elseans+= (A[MINA]==B[MAXB]), mina++,maxb--; } returnans;}intMain () {n=read (); for(intI=1; i<=n;i++) scanf ("%d",&A[i]); for(intI=1; i<=n;i++) scanf ("%d",&B[i]); Sort (a+1, A +1+N); Sort (b+1, B +1+N); printf ("%d", Solve ()); Swap (A, b); printf ("%d\n",2*n-solve ());}
Bzoj [ZJOI2008] Bubble Hall BNB Greedy