1034: [ZJOI2008] Bubble Hall BNB

Source: Internet
Author: User

1034: [ZJOI2008] Bubble Hall BNBDescription

  During the Noi period, in order to strengthen the exchanges between the provinces, the organizing committee decided to organize an inter-provincial e-sports competition, the representative of each province
The team is made up of N players and the event is an online game bubble Hall for all ages. Before each match, the coaches of the two sides submitted a copy to the organizing committee
The list of contestants determines the order in which the contestants will play and shall not be modified once determined. In the race, a contestant of both sides, contestant No. second ..., n
Players to catch the fight, a total of n games. Each win a match 2 points, the level of 1 points, lose a score. end up adding a single field score to both sides
Get the total score, the high score of the team to advance (the total score of the same decision). As the leader of Zhejiang team, you have already put all the players in the province in advance to the bubble Hall water
Know the plain and measure it with a strength value. To simplify the problem, we assume that the player is completely unaffected by any external factors in the game.
, that the strength of the players must be able to overcome the weak players, and two players of the same strength must fight flat. Because I have no idea what the opponent will use
Strategies to determine the order of appearances, so all teams have adopted a strategy of completely randomly determining the order of appearances. Of course you don't want to do that.
The game is not white. 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 N-position of the players in the Zhejiang team
Strength value. The next n lines, an integer per line, describe the strength of your opponent's N-players. The number of,1<=n<=10; 40% in 20% of the data
According to the data in,1<=n<=100; 60%,1<=n<=1000; 100% of the data, 1<=n<=100000, and the strength of all players in 0 to 100
Between 00000.

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 excess at the end of the line
White space characters.

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 0220The following:It's a good idea to avoid horse racing with that field. Of course there are many, I will only greedy. personally, the greedy strategy is still very obvious, the weakest can win the win (and the enemy's weakest ratio), the strongest is also the case, if not, then use their weakest to offset the strongest.
#include <stdio.h>#include<iostream>#include<algorithm>#include<string.h>using namespacestd;intn,i,j,a[100005],b[100005];intSolveinta[100005],intb[100005]){    intans=0, x=1, y=n,l=1, r=N;  while(x<=y) {if(a[y]>B[r]) {y--; R--; Ans+=2; } Else        if(a[x]>B[l]) {x++; L++; Ans+=2; } Else        {            if(A[x]==b[r]) ans++; X++;r--; }    }    returnans;}intMain () {scanf ("%d",&N);  for(i=1; i<=n;i++) scanf ("%d",&A[i]);  for(i=1; i<=n;i++) scanf ("%d",&B[i]); Sort (a+1, a+n+1); Sort (b+1, b+n+1); printf ("%d%d", Solve (A, b),2*n-solve (b,a)); return 0;}

1034: [ZJOI2008] 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.