Maximum Product of K Integers

View as PDF

Submit solution

Points: 25
Time limit: 0.6s
Memory limit: 1G

Problem type

You're given a sequence of N integers. Let f(L) be the product of all integers in sequence L. Over all subsequences s of length K of the original sequence, compute the maximum possible value of f(s).

Unlike other problems on DMOJ, the data for this problem will be user-contributed, leveraging DMOJ's ability to look at solutions that have AC on them. If you have a test case to contribute, please DM it to xiaowuc1 along with the ID of another user's submission that fails the provided test case, and your submission that passes on the given test case. Credit for test data will be given in the problem statement.

Users who copy other persons' submissions will be banned from submitting to this problem.

Number of test cases present: 13

  1. Sample.
  2. Sample.
  3. Provided by ksun48.
  4. Provided by wleung_bvg.
  5. Provided by Rimuru.
  6. Provided by Rimuru.
  7. Provided by Rimuru.
  8. Provided by Beautiful_Times.
  9. Provided by d.
  10. Provided by d.
  11. Provided by xiaowuc1.
  12. Provided by d.
  13. Provided by d.

Constraints

1 \le K \le N \le 10^5

|a_i| \le 10^9

Input Specification

The first line contains two space-separated positive integers, N and K.

The next line contains N space-separated integers, the sequence of integers a_i.

Output Specification

Output the maximum possible product.

Sample Input 1

1 1
1

Sample Output 1

1

Sample Input 2

1 1
0

Sample Output 2

0

Comments

There are no comments at the moment.