АВТ
Язык:

Дистанционный практикум по программированию

Задачи Online статус Соревнования
Новости Справка СДО
 
Здравствуйте, Гость! Войдите с паролем или зарегистрируйтесь.

615. Lawyers Council

Ограничение времени: 2 сек.
Ограничение памяти:65536 КБайт
Баллы:100
Статистика Послать на проверку Задачу добавил debug

The king of Byteland decided to talk with N lawyers about a very important federal law. Each lawyer is specialized in the separate area, that's why the king can talk only with one lawyer at a time. It's known that to talk with i-th lawyer the king needs Ti minutes. Also it's known, that i-th lawyer demands Ci dollars for each minute of his work time (it includes the talk time and the time this lawyer had to wait for the king). All lawyers came to the king at the same time. Now the king has to find the minimal sum, that he can pay to lawyers for their work.

Input
In the first line of input file an integer number N is written - the number of lawyers (1 ≤ N ≤ 105). In the second line N integer numbers Ti are written - separated by a space. Third line contains integer numbers Ci, also separated by a space. All numbers are from 1 to 1000 inclusive.
Output
Output just one number - the minimal sum.

Input 1 Output 1 Input 2 Output 2
2
3 2
1 2
9
6
20 4 6 13 56 12
87 34 23 5 12 90
7281

In the first example it's more profitable to talk with the second lawyer, and after that with the first

Статистика Послать на проверку Обсуждение задачи Автор/источник:
Задачи с соревнований и сборов / Чемпионаты в Коврове / КИТ-2008 /
613. Division 615. 608. Math and Soldiers 612. Points 609. Roads
 
время генерации 0.141 сек.
© Copyright ВоГУ, АВТ, Носов Д.А., Андрианов И.А.