CODEFORCES ROUND 672 POKEMON ARMY ANOTHER APPROACH (NO DP)

Watch this video for understanding another approach to this problem:

video link: