[Solution] Army Training CodeChef Solution | Solution Codechef
Chef is a high-ranked army officer and he has been given the job to train the army.
The army consists of soldiers where each soldier has parameters:
- Attack points: where ;
- Defense points: ;
- Soldier type:
ATTACK
orDEFENSE
.
For the whole army:
- Attack value of the army is defined as the sum of attack points of all
ATTACK
type soldiers. - Defense value of the army is defined as the sum of defense points of all
DEFENSE
type soldiers. - Rating of the army is defined as the product of Attack value and Defense value of the army.
Assign the soldier type to each of the soldiers to maximize the rating of the army. Print the maximum rating.
NOTE: The output may exceed the range of a -bit integer.
Remember to use -bit data types, such as long long
in C++
.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
Counting Words CodeChef Solution
MATH1 Enrolment CodeChef Solution
Group Assignment CodeChef Solution
Army Training CodeChef Solution
Sort the String CodeChef Solution
Vowel Anxiety CodeChef Solution
Array sorting CodeChef Solution
- Each test case consists of multiple lines of input.
- The first line of each test case contains an integer — the number of soldiers in the army.
- The next line contains the array — where denotes the attack points of the soldier.
Output Format
For each test case, output on a new line the maximum possible rating that can be achieved.
Constraints
- Sum of over all test cases does not exceed
No comments:
Post a Comment