Molly is trying to steal some candy from her best friend FatalWhale. Unfortunately, FatalWhale is very organized and will immediately notice if the total sweetness of candies Molly takes is not a multiple of . Help Molly determine which candies out of the FatalWhale has in order to take the maximum sweetness!
Constraints
- You will receive of the points if you find just the maximum sweetness, but in order to receive these points, you must correctly follow the output specification.
- Molly will always take at least one candy.
Input Specification
On the first line of input you will find two space-separated integers, and .
On the second line of input you will find the sweetness of the candies, as space-separated integers .
Output Specification
On the first line you will print the maximum sweetness.
On the second line you will print the number of the candies that Molly takes in order to take the maximum sweetness.
On the third line, you will print the indices of the candies Molly takes.
Sample Input
7 6
178 25 123 34 56 79 100
Sample Output
570
6
1 3 4 5 6 7
Sample Output [for 20% of points]
570
1
1
Comments
Impossible to do it within time and memory limits with Python.
Not all problems on the judge are solvable in Python by design. In this case, though, your approach's complexity is such that it would TLE on similar cases even if it were implemented in C++ — there is a faster approach.
Good luck!
Yes but is it at least possible to get different Time Limit constraints like on other problems? (I can write C++ code just fine, but, to be fair, 0.18 seconds is too strict for even Java, let alone Python.)