IOM 2018, Блиц, английски — Задача 60

OLYMPIAD OF METROPOLISES. Moscow, September 3 · 3 септември 2018 г.

Условие

What should be the value of pp in the input in order to get 20 as the output?

Python program listing with line numbers 1 to 12: def mystery(k, ar, p) loops while k < len(ar) - 1, swaps ar[k] and ar[k + 1] by additions and subtractions when ar[k] > ar[k + 1] and resets k to 0, otherwise increments k, and returns a[p] + a[p - 1]; then p = int(input()), ar = [15, 20, 2, 5, 18] and print(mystery(0, ar, p)).

Отговори

Решение


Оригинал в Архива: blitz.pdf · официални решения: blitz-answers.pdf