F - Everywhere is Sparser than Whole (Judge) Editorial by i_am_noob

Similar Problem

https://codeforces.com/contest/1835/problem/F