Back
Close
  • 25

Statement

 Goal

You must rearrange the digits in the string S into two numbers A and B according to the following rules:
0 ≤ A, B ≤ 10^18;
No leading 0's. "0" is a valid number; "000" is not;
Minimize A, then minimize B.

Source: BSUIR Open Programming Championship
Input
The first and the only line contains string S consisting of digits only.
Output
Output two numbers A and B separated by space. If such numbers can't be formed then output -1 -1.
Constraints
1 ≤ length of S ≤ 50
0 ≤ A, B ≤ 10^18
Example
Input
72
Output
2 7
Solve it

A higher resolution is required to access the IDE

codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants