ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Сборники > Kovrov IT > задача:


2008.H. 50254 - Lawyers Council

Гость
• Обсуждение задачи (1)

Задачи сборника

• 2007.K. 50276 - Nice Floor
• 2008.A. 50672 - Math and Soldiers
• 2008.B. 50261 - Roads
• 2008.C. 50262 - Brackets
• 2008.D. 50279 - Bit Decoder
• 2008.E. 50263 - Points
• 2008.F. 50972 - Division
• 2008.G. 50264 - String Multiplication
• 2008.H. 50254 - Lawyers Council
• 2009.A. 50283 - Tetris 3D
• 2009.B. 50284 - Knights of the Rook
• 2009.C. 50285 - Meat store
• 2009.D. 50259 - Many-coloured roads
• 2009.E. 50266 - Kovrov
• 2009.F. 50267 - Interesting permutat...
• 2009.G. 50260 - What about judges?
• 2009.H. 50268 - Triangles

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Автор: Павел Кузнецов, ПГУ.

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.

Для отправки решений необходимо выполнить вход.

www.contester.ru