#P1673. [USACO05FEB] Part Acquisition S

[USACO05FEB] Part Acquisition S

Output Format

Output the minimum number of distinct item types.

6 5
1 3
3 2
2 3
3 1
2 5
5 4
4

Hint

The cows need at least 44 different labels: first exchange 11 for 33, then 33 for 22, and finally 22 for 55.

1N5×1041\le N\le 5\times 10^4, 1K1031\le K\le 10^3.

Translated by ChatGPT 5