#P1441. 砝码称重

砝码称重

Description

There are nn weights with masses aia_i. After removing exactly mm weights, ask for the maximum number of different measurable weights (excluding 00).

Note that weights can only be placed on one side of the balance.

Input Format

The first line contains two integers nn and mm, separated by a space.

The second line contains nn positive integers a1,a2,a3,,ana_1, a_2, a_3, \ldots, a_n, representing each weight’s mass.

Output Format

Output a single integer: the maximum number of different measurable weights.

3 1
1 2 2
3

Hint

[Sample Explanation]

After removing one weight of 22, you can measure 1,2,31, 2, 3, for a total of 33 distinct weights.

[Constraints]

  • For 20%20\% of the testdata, m=0m = 0.
  • For 50%50\% of the testdata, m1m \leq 1.
  • For 50%50\% of the testdata, n10n \leq 10.
  • For 100%100\% of the testdata, n20n \leq 20, m4m \leq 4, m<nm < n, ai100a_i \leq 100.

Translated by ChatGPT 5