Question: You are trying to improve your competitive programming skills and you have listed all the problems along with their difficulty level. You have to plan

You are trying to improve your competitive programming skills and you have listed all the problems along with their difficulty level. You have to plan your schedule in order to maximize your skills.
You are given an integer array difficultyLevel[] of size N denoting the difficulty levels of N problems listed. You are provided with an integer K denoting the exact number of problems you can solve in a day. The skill you achieve after solving all the problems is defined as the summation of the products of the difficulty levels of all the problems solved each day.
Your task is to design a schedule that can maximize your skill at the end of this exercise and return the maximum skill you can attain. As the answer is too large, return the answer modulus 10^9+7.
Note: Before multiplying the difficulty levels of two integers A and B, you need to reduce each integer to (A%10^9+7) and (B %10^9+7).
Input Specification:
input1: an integer array denoting difficultyLevel[]
input2: an integer N denoting the length of the array difficultyLevel[]
input3: an integer K denoting the exact number of problems you can solve each day.
Output Specification:
An integer denoting the maximum skill you can attain.
Example 1:
input1: [10,12,2,5,1,9]
input2: 6
input3: 2
Output: 167
Explanation:
The value of mod 1000000007 i.e 10^9+7.
On day 1, we can solve problems with difficulty levels 10 and 12. Thus the product is ((10)%mod)*((12)%mod)=120 refer to Note above
On day 2, we can solve problems with difficulty levels 5 and 9. Thus the product. is ((5)%mod)((9)%mod)=45.
On day 3, we can solve problems with difficulty levels 2 and 1. Thus the product is =((2)%mod)*((1)%mod)=2.
The summation of the products of the difficulty levels of all the problems solved each day =2+45+120=167 and (167% mod)=167. This is the maximum possible skill that can be achieved. Therefore, 167 will be returned as the answer.
Example 2:
input1: [2,10,50,32]
input2: 4
input3: 2
Output: 1620
Explanation:
On day 1, we can solve problems with difficulty levels 2 and 10. Thus the product is ((2)%mod)*((10)%mod)=20.
On day 2, we can solve problems with difficulty levels 32 and 50. Thus the product is ((32)%mod)*((50)%mod)=1600.
The summation of the products of the difficulty levels of all the problems solved each day =20+1600=1620 and (1620% mod)=1620. This is the maximum possible skill that can be achieved. write a c++ code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!