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

Турниры > CEN303 2013-15 Questions > задача:


14-FallResit-20. 50488 - Connecting Wires

CEN303 2013-15 Questions

Старт: 15.дек.2013 в 14:00:00
Финиш: 15.дек.2013 в 19:00:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (2)

Задачи турнира

• 14-Fall1-50. 50770 - Average Depth
• 14-Fall1-60. 50784 - Top Growing C...
• 14-Fall2-10. 50751 - The biggest Mi...
• 14-Fall2-20. 50794 - Writing Files Int...
• 14-Fall2-30. 50490 - Across the River
• 14-Fall2-40. 50772 - The Path of a N...
• 14-Fall2-50. 50681 - Center of a Series
• 14-FallResit-10. 50525 - Ordering Pizza
• 14-FallResit-20. 50488 - Connec...
• 15FE-01. 50851 - Repeated Numbers
• 15FE-01. 50838 - Balanced Numbers
• 15FE-04. 50997 - Dynamic Knights
• 15HW-10. 50826 - Olive Containers
• 15HW-30. 50828 - Arranging Time ...
• 15HW-40. 50676 - Cinema Millennium
• 15HW-40. 50829 - Decode an Image
• 15HW-50. 50830 - Sorting BST Nodes

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

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

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question adapted by Ibrahim Mesecan.

Connecting Wires

On random positions, there are n white dots and n black dots, equally spaced, in a line. You want to connect each white dot with some one black dot, with a minimum total length of "wire".


Total wire length above is 1 + 1 + 1 + 5 = 8.

Question:
Write a program that reads a number n. And then, it reads (n) strings ("Black" or "White"). Your program, in the end, must calculate and show the minimum length of the wire needed.

Input specification
The first line contains an integer (n) where 1 ≤ n ≤ 20000 and represents the number of "Black" and "White" dots. Then, in the following n lines, you will be given n strings.

Output specification
A single integer which shows the total minimum length of wire that is needed to connect all Black and White dots.

Sample Input I   
4
Black
Black
White
Black
White
White
White
Black
Sample Input II   
4
Black
Black
White
Black
White
Black
White
White
Sample Output I   
8
Sample Output II   
10


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

www.contester.ru