Digit Sum Minimization

AtCoder
IDarc130_c
Time2000ms
Memory256MB
Difficulty
Given are positive integers $a, b$, where none of the digits is $0$. Permute the digits of each of $a$ and $b$ so that the sum of the digits in $a+b$ is minimized. ## Constraints * $1\leq a, b< 10^{100000}$ * None of the digits of $a$ and $b$ is $0$. ## Input Input is given from Standard Input in the following format: $a$ $b$ [samples]
Samples
Input #1
253
286
Output #1
532
268

We have $532 + 268 = 800$, whole digits sum to $8+0+0=8$.
Other solutions will also be accepted, such as $(a, b) = (325, 682)$.
Input #2
345
556
Output #2
435
565

We have $435+565=1000$, whole digits sum to $1+0+0+0=1$.
Input #3
123
987987
Output #3
312
799788

We have $312 + 799788 = 800100$, whole digits sum to $8+0+0+1+0+0=9$.
Input #4
11111111111111111111
111111111111111111111111111111
Output #4
11111111111111111111
111111111111111111111111111111
API Response (JSON)
{
  "problem": {
    "name": "Digit Sum Minimization",
    "description": {
      "content": "Given are positive integers $a, b$, where none of the digits is $0$. Permute the digits of each of $a$ and $b$ so that the sum of the digits in $a+b$ is minimized.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc130_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given are positive integers $a, b$, where none of the digits is $0$.\nPermute the digits of each of $a$ and $b$ so that the sum of the digits in $a+b$ is minimized.\n\n## Constraints\n\n*   $1\\leq a, b< 10...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments