Purchase problem solving Задача #7788

Задача

Excerpts from the work