AtCoder Beginner Contest 221 C - Select Mul 【Python】

https://atcoder.jp/contests/abc221/tasks/abc221_c

AtCoder ProblemsのRecommendationで Difficulty: 379、Solve Probability: 50%でした。

解けませんでした。よくあるのですが、制約の10**9を見た瞬間に全探索では解けないと決めつけてしまっていました。

サンプルを見て思いついたものとしては、Nを降順にソートして、
A:①④⑤
B:②③⑥
といった順に振り分ければ良いのではと思ったのですが、一部のケースだけが通るのみでした。
こちらの解法
https://atcoder.jp/contests/abc221/editorial/2730
が強いて言えば近いかなと思いました。

解説(全探索)
https://atcoder.jp/contests/abc221/editorial/2720

from itertools import permutations
N = list(input())
 
len_n = len(N)
ans = 0
for p in permutations(N):
    for i in range(1, len(N)):
        a = p[:i]
        b = p[i:]
 
        a = int(''.join(a))
        b = int(''.join(b))
        ans = max(ans, a * b)
print(ans)