Codeforces и Polygon могут быть недоступны в период с 23 мая, 7:00 (МСК) по 23 мая, 11:00 (МСК) в связи с проведением технических работ. ×

Блог пользователя fkndonttrespass

Автор fkndonttrespass, история, 16 месяцев назад, По-английски

You are given two integers x and y and array a of n integers. x is initially equal to zero. For every element in the a you can either add it to x, or you can subtract it from x. You have to tell whether you can make the number x equal to the number y by any means. An O(n^2) approach would work too. Additionally all the elements of a are <=300, I don't know if it's of any use.

Note that x should be compared to y only after all the elements of a are either added to it or subtracted from it.

Thanks.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится