CODEFORCES ROUND 672 POKEMON ARMY ANOTHER APPROACH (NO DP)

Watch this video for understanding another approach to this problem:
https://codeforces.com/problemset/problem/1420/C1

video link: