There are \(n\) integers \(a_1, a_2, …, a_n\) in an array \(A\). It's guaranteed that any two digits in \(a_i\) won't be the same. Suppose you can swap two digits of \(a_i\) in the array at most \(m\) times. The cost
of each swap is \(k\). We define \(S = \sum A – x \times k\), where \(x\) is the times of
swapping applied, \(A\) is the corresponding integer array after \(x\) times swapping actions. Please find the maximum value of \(S\).