Can anybody explain me this code of tourist from yesterday's contest?

Правка en2, от Rock2000, 2020-07-05 14:58:59

Problem link

Tourist Code

What I do not understand is how after finding array b we get the correct answer.
Thanks in advance.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Rock2000 2020-07-05 14:58:59 86 Tiny change: ' b we get correct a' -> ' b we get the correct a'
en1 Английский Rock2000 2020-07-05 14:57:14 1062 Initial revision (published)