Выбрать соревнование | Задачи | Послать решение | Результаты проверки | Статистика по задачам | Вопросы и ответы | Результаты соревнования | Состояние сервера | Изменить данные | Управление командой | Помощь |
29/03/2025 | Открытые командные соревнования по спортивному программированию "PRIME TIME" ( 3) |
29/03/2025 | ЦОП: дорешивание Prime Time 2025 (проводит BOGAT) (B) |
Ограничения: время – 250ms/500ms, память – 256MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод
Послать решение Blockly Посылки Темы Где Обсудить (0)
All residents of the Emerald City must wear green T-shirts for the party. There are five sizes of T-shirts in stock: XS, S, M, L, XL. A resident can wear either their size or one size larger. For example, a person who wears size M will also wear a T-shirt of size L, but T-shirts of sizes XS and S will be small for them, and a T-shirt of size XL will be too big. Determine how many residents of the city can wear T-shirts and come to the party.
The first input line contains five integers XS,S,M,L,XL (0≤XS,S,M,L,XL≤109) — the number of T-shirts of the corresponding size. The second input line contains five integers A,B,C,D,E (0≤A,B,C,D,E≤109) — the number of city residents who wear T-shirts of sizes XS, S, M, L, XL respectively.
Output one integer — the maximum number of residents who will be able to attend the event in green T-shirts.
Sample Input
2 3 0 1 10 4 2 1 2 2
Sample Output
10
Example explanation: 4 residents of size XS can take 2 T-shirts of size XS and 2 T-shirts of size S, one of the 2 residents of size S takes 1 T-shirt of size S and the other stays at home, 1 resident of size M takes 1 T-shirt of size L, 2 residents of size L and 2 residents of size XL take 4 T-shirts of size XL. In total, 10 residents will be able to attend the party.