Auto-translated
Oh, come on, it all worked out somehow.
Initially, I planned for 7 days, but then I had to replay to capture the Wizard's Castle on day 4, and then I realized that on that day, I could capture two out of the three remaining castles.
Day 2 - capturing the Barbarian's Castle and defending against a hero.
Day 3 - capturing the Warlock's Castle and defending against a hero.
Day 4 - capturing the Wizard's Castle, defending against a hero, and capturing the Sorceress's Castle.
Day 5 - capturing the Knight's Castle and killing the last hero on the map (the Knight. Sometimes the Knight would defeat the Sorceress and return to recapture his castle; once out of 30 times, I managed to defend against him).
In general, the main idea was to force the hero to attack after capturing the castles, and have the Sorceress and Knight battle on day 4.