Help me in codeforces problem

i try to solve by java but i can’t

can anyone help me please ?