Title Description
JWJU focus on students "sing, dance, rap, basketball" capability. So JWJU school basketball tournament held every year, a platform to demonstrate their basketball skills to the students. School champion of women's reward is to see wls once, to this end, we all work hard, I hope to be able to see wls women.
Coach my men have n players, and now he has to pick 5 -person team to a basketball competition. As we all know, a basketball team has five different positions (point guard, shooting guard, small forward, power forward, center), now coach My m ability of each team member at each position y is given.
Note: If a player played as a point guard, he can only play to the ability value of his point guard. (Other similar position)
Coach My m the y-want you to help choose the 5 players, teams were placed in a different location. The maximum capacity of the composition of teams seeking their values and.
Enter a description
Output of the first line contains a positive integer n- ( . 5-n-10-^ . 5 .
Next comprising n- n-rows, each row containing . 5 positive integer, describes the ability value of each player at each position. Ability value of each range are [^ {9, 10}
Output Description
The maximum value and the ability to output a line a positive integer composed of representatives of the team.
Sample input 1
5 10 11 12 15 10 10 15 12 11 10 15 10 15 15 15 19 20 114000 10 300 14 10 155 200 469
Sample output 1
114514
prompt
The first person in position 4, values of the ability to play 15
2 on the location of the second person, the value of the ability to play 15
Third person in position 1, the value of the ability to play 15
The fourth person in position 3, the ability to play the value 114 000
A fifth person in position 5, the value of the ability to play 469
Team total capacity value: 15 + 15 + 15 + 114 000 + 469 = 114 514
Ideas: five positions for each position before the election five strongest total of 25 people (duplicate)
Then deep seized the maximum (use to visit an array)
#include <bits / STDC ++ H.> the using namespace STD; #define LL Long Long BOOL VIS [ 100005 ]; LL CO.'s [ 100005 ] [ . 6 ]; LL Mmax [ . 6 ] [ . 6 ], ANS = 0 ; void DFS ( int now, LL tmp) { // now a first columns see an IF (now == . 6 ) { ANS = max (ANS, tmp); return ; // be sure to return i.e. not following for loop } for ( int i =. 1 ; I <= . 5 ; I ++ ) { IF (VIS [Mmax [I] [now]]) Continue ; // to see whether the line visit through VIS [Mmax [I] [now]] = . 1 ; DFS (now + . 1 , tmp + CO.'s [Mmax [i] [now]] [now]); VIS [Mmax [i] [now]] = 0 ; } } / * Mmax [i] [j] j-th column of the i-large number faction (i.e., the first few lines) Mmax array . 4. 5. 4. 5. 4 . 3. 4 2. 5. 1 . 5. 1. 3. 3. 3 . 1. 3. 1 2. 1 2. 5. 4 2 2 * / int main () { LL n-; CIN >>n-; for ( int I = . 1 ; I <= n-; I ++ ) { for ( int J = . 1 ; J <= . 5 ; J ++ ) { CIN >> CO.'s [I] [J]; for ( int POS = . 1 ; POS <= . 5 ; POS ++) // front to back is determined whether the number of which is larger than the presence of { iF (CO.'s [I] [J]> CO.'s [Mmax [POS] [J]] [J]) { for ( int = K . 5 ; K> = + POS . 1; K--) // big to be pushed back and exit the loop Mmax [K] [J] Mmax = [- K- . 1 ] [J]; Mmax [POS] [J] = I; BREAK ; } } } } DFS ( . 1 , 0 ); COUT << ANS << endl; }