Educational Codeforces Round 78 (Rated for Div. 2)

anyone please help with easy explanation to this problem: