Editorial for DMOPC '21 Contest 6 P1 - Bigger Big Integer
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
For this subtask, notice that the tens digit contributes more towards the value of the number than the ones digit, so we should always ensure that it is the larger of the two digits.
Time Complexity:
Subtask 2
For this subtask, we may simply simulate swapping every pair of adjacent digits and compare it to the current best answer (using either a String
or BigInteger
class).
Time Complexity:
Subtask 3
For this subtask, note that we should swap at the first index pair and for which . Intuitively, increasing the value of the -th digit is better than increasing the value of any later digit because of the relative significance of each place value.
Time Complexity:
Comments