Task - Level1 Algorithm Module
Task - Level1 Algorithm Module
Implementation:
● Nearest Stores should be located using Dijkstra Algorithm
● Final Order Items should be filtered by Knapsack Algorithm [Dynamic
Programming approach only]
● We don’t ask for UI design, solution can be processed in console way inputs
Coding Details:
● User should be able to pass the input
● Code documentation should be added
Implementation:
● Colors used in one level should be n-1 where n is number of Stacks
● After 3 levels we should increase the number of stacks and colors
● The random generation of colors in a stack should never be in such a way that it is a
np-complete problem. It should always be possible to solve the level.
● We don’t ask for UI design, solution can be processed in console way inputs
Coding Details:
● User should be able to pass the input
● Code documentation should be added
3.) Problem: Akash needs every accumulator to contain the same amount of energy. Initially every
accumulator has some amount of energy: the i- th accumulator has ai units of energy. Energy can be
transferred from one accumulator to the other. Every time x units of energy are transferred (x is not
necessarily an integer) k percent of it is lost. That is, if x units were transferred from one accumulator
to the other, amount of energy in the first one decreased by x units and in other increased by
units.
Your task is to help Akash find what maximum equal amount of energy can be stored in each
accumulator after the transfers.
Input
First line of the input contains two integers n and k (1 ≤ n ≤ 10000, 0 ≤ k ≤ 99) — number
of accumulators and the percent of energy that is lost during transfers.
Next line contains n integers a1 , a2, ... , an — amounts of energy in the first, second, .., n- th
accumulator respectively (0 ≤ ai ≤ 1000, 1 ≤ i
≤ n) .
Output
Output maximum possible amount of energy that can remain in each of accumulators after the
transfers of energy.
The absolute or relative error in the answer should not exceed 10 - 6.
Example:
Input
3 50
421
Output:
2.000000000
Input
2 90
1 11
Output
1.909090909