BZOJ1034 [ZJOI2008] Bubble Hall BNB

Source: Internet
Author: User

Description

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 0Positive solution: GreedyProblem Solving Report:This problem is a DP approach, but I am Konjac Konjac, think DP so can only choose greedy. This problem is Tian bogey horse racing, the strategy is very simple, if the current worst than the other side of the worst now, let the current worst than the other side of the worst ratio (obviously the current is the worst, in the worst of the premise, must be out of the worse the better); Then compare the strongest of the current and the strongest of the other, if stronger than the other side of the direct comparison. if they are not satisfied, consider using their own worst direct and the other side of the strongest ratio, which is obviously feasible, anyway, the other side of the strongest can not win, then it is better to use their worst to replace each other's strongest. This is the optimal strategy, the worst strategy is to take the other side as the initiative, run through the optimal strategy, and then use 2xn-ans to get the worst strategy.
start A, b array to write the reverse of a place, and then WA a few rounds. mdzz

1 //It's made by jump~2#include <iostream>3#include <cstdlib>4#include <cstring>5#include <cstdio>6#include <cmath>7#include <algorithm>8#include <ctime>9#include <vector>Ten#include <queue> One#include <map> A#include <Set> - #ifdef WIN32 - #defineOT "%i64d" the #else - #defineOT "%lld" - #endif - using namespacestd; +typedefLong LongLL; - Const intMAXN =100011; + intN,ans; A intA[MAXN],B[MAXN]; at  -InlineintGetint () - { -        intw=0, q=0; -        CharC=GetChar (); -         while((c<'0'|| C>'9') && c!='-') c=GetChar (); in        if(c=='-') q=1, c=GetChar (); -         while(c>='0'&& c<='9') w=w*Ten+c-'0', c=GetChar (); to        returnQ? -w:w; + } -  theInlinevoidSolveintA[],intb[]) { *ans=0; $     intl1=1, R1=N,L2,R2; L2=L1; R2=R1;Panax Notoginseng      while(L1<=r1 && l2<=R2) { -     if(A[l1]>b[l2]) ans+=2, l1++,l2++; the     Else if(A[R1]&GT;B[R2]) ans+=2, R1--, r2--; +     Else{ A         if(A[L1]==B[R2]) ans+=1; thel1++; r2--; +     } -     } $ } $  -InlinevoidWork () { -n=getint (); the      for(intI=1; i<=n;i++) a[i]=getint (); -      for(intI=1; i<=n;i++) b[i]=getint ();WuyiSort (A +1, a+n+1); Sort (b +1, b+n+1); the  - Solve (A, b); Wuprintf"%d", ans);  -  About solve (b,a); $printf"%d",2*n-ans); - } -  - intMain () A { + Work (); the   return 0; -}

BZOJ1034 [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.