[Bzoj 1034] [Zjoi 2008] Bubble Hall BNB

Source: Internet
Author: User

1034: [ZJOI2008] Bubble Hall BNB time limit:10 Sec Memory limit:162 MB
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 Input2
1
3
2
4Sample Output2 0
Sample Description
We say 4 players are a,b,c,d respectively. The following 4 types of PvP may be present, preferably 2 points, and a worst case score of 0.
One two three four
Zhejiang??? Results Zhejiang??? Results Zhejiang??? Results Zhejiang??? Results
One player AC negative ad negative BC WINS BD negative
Player number second BD negative BC WINS AD negative AC negative
Total Score 0220" The Puzzle"can use the weakest to win each other's weakest to do so, can use the strongest win each other's strongest also do so,other situations put their weakest hit each other the strongest, which is the maximum score. the minimum score is to change the position between yourself and the other, and then subtract ans with 2*n.
1#include <iostream>2#include <stdio.h>3#include <string.h>4#include <stdlib.h>5#include <math.h>6#include <string>7#include <algorithm>8 using namespacestd;9 intN;Ten inta[100010],b[100010]; One  AInlineintRead () { -     intx=0, f=1;Charch; -Ch=GetChar (); the      while(ch>'9'|| ch<'0') {if(ch=='-') f=-1; Ch=GetChar ();} -      while(ch<='9'&&ch>='0') {x= (x<<1) + (x<<3) +ch-'0'; ch=GetChar ();} -     returnx*F; - } + intMain () { -n=read (); +      for(intI=1; i<=n;++i) a[i]=read (); A      for(intI=1; i<=n;++i) b[i]=read (); atSort (A +1, a+n+1); -Sort (b +1, b+n+1); -     inth1,h2,t1,t2,ans=0; -H1=h2=1; t1=t2=N; -      while(h1<=T1) { -         if(A[H1]&GT;B[H2]) ans+=2, h1++,h2++; in         Else if(A[t1]>b[t2]) ans+=2, T1--, t2--; -         Else { to             if(A[h1]==b[t2]) ans+=1; +h1++;t2--; -         } the     } *printf"%d", ans); $H1=h2=1; t1=t2=n;ans=2*N;Panax Notoginseng      while(h1<=T1) { -         if(B[H1]&GT;A[H2]) ans-=2, h1++,h2++; the         Else if(B[t1]>a[t2]) ans-=2, T1--, t2--; +         Else { A             if(B[h1]==a[t2]) ans-=1; theh1++;t2--; +         } -     }     $printf"%d", ans); $     return 0; -}
View Code

[Bzoj 1034] [Zjoi 2008] Bubble Hall BNB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.