E Match Rating

Time limit: - MS    Space limitations: - KB 
Benchmark description: 1s, 128m
Problem Description

Lj recently participated in a talent contest, there are N judges took part in the score, N is odd.
Judges are numbered 1 to N. The judges to score each Lj is an integer, the judges scoring is .
The use of an innovative method to calculate the final score, the calculation rule is:
  first N bits in a row the judges, three judges of the inspection team score first row, remove a maximum points and a minimum score, the rest of a judge move the team to the final, the above operation is repeated until only one team of judges, then the judges scoring Lj is the final score.
Because some older and judges, can not remember his position, and now there is a jury quickly found his place, the rest of the people can not find a location, they need to rearrange the position.
Since Lj want to score as high as possible. LJ help you calculate the final score the maximum possible.

Input Format

A first integer N and behavior M, separated by spaces. N expressed panelists, who wherein M initial arrangement position has been determined.

The next row in row i and M are both integers and , separated by a space.

Denotes the i panelists rated Di, initial alignment position for the first position Pi queues at the beginning of the head. The next line of behavior integer i representing judges (i + M) is rated . 999 ≦ N ≦ 99. 3,
. 1 ≦ M ≦ N -
2, ,
. 1 ≦ N ≦ Pi (. 1 ≦ I ≦ M),
! Pi = Pj of (. 1 ≦ I <J ≦ M).

Output Format

Output line, is an integer that represents the maximum score LJ.

Sample input 1

7 3 
5 2 
5 5 
8 6 



9

Sample output 1

8

Sample input 2

9 2
700064284 3
805336870 6
503971033
711342034
929082548
143239206
42519425
58389173
572744325

Sample output 2

700064284

prompt

Sample Description 1: // the highest scoring alignment score: 2, 5, 6, 8, 5, 8, 9

【analysis】
 
[Standard] Cheng

Guess you like

Origin www.cnblogs.com/Limbo-To-Heaven/p/11369648.html