[Solution] Maximum Product? Codeforces Solution | Codeforces Problem Solution 2022
H. Maximum Product?
time limit per test
1.5 secondsmemory limit per test
512 megabytesinput
standard inputoutput
standard outputYou are given a positive integer . For a multiset of integers , define as the following.
- If the number of elements in is less than , .
- Otherwise, define as the maximum product you can get by choosing exactly integers from .
More formally, let denote the number of elements in . Then,
- If , .
- Otherwise, .
You are given a multiset of integers, . Compute modulo .
Note that in this problem, we distinguish the elements by indices instead of values. That is, a multiset consisting of elements always has distinct subsets regardless of whether some of its elements are
👇👇👇👇👇
equal.
Input
The first line of input contains two integers and , where is the number of elements in ().
The second line of input contains integers , describing the elements in ().
Output
Output modulo .
No comments:
Post a Comment