#K2081. Maximum Distinct Bird Species

    ID: 24657 Type: Default 1000ms 256MiB

Maximum Distinct Bird Species

Maximum Distinct Bird Species

Alice wants to photograph as many distinct bird species as possible in a day. She visits several bird watching locations. At each location, the number of available different bird species is given, but she can only spend a limited number of minutes M at that location. In each minute, she can photograph one species, but she cannot photograph more than what the location offers. Therefore, for the i-th location with si available species, the maximum species she can photograph at that location is given by \(\min(M, s_i)\).

The task is to compute the total maximum number of distinct bird species Alice can photograph across all locations for each test case.

inputFormat

The input begins with an integer T, the number of test cases. For each test case:

  • The first line contains two integers N and M, where N is the number of locations and M is the maximum minutes Alice can spend at each location.
  • The second line contains N integers, where each integer represents the available number of distinct bird species at that location.

outputFormat

For each test case, output one line containing a single integer — the total maximum number of distinct bird species that Alice can photograph. This is computed as \(\sum_{i=1}^{N} \min(M, s_i)\).

## sample
2
4 2
5 3 2 4
3 1
7 3 2
8

3

</p>