PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000040. Robot hút bụi (Robot Vacuum Cleaner)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Robot hút bụi (Robot Vacuum Cleaner)
Robot Vacuum Cleaner
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are strings consisting only of s and h. Concatenate them in some order. The score is the number of pairs with , character equal to s and character equal to h. Maximize the score.
Input
The first line contains . Each of the next lines contains one string.
Output
Print the maximum score.
Constraints
- .
- và .
- Each character of is
sorh..
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): Full constraints.
Examples
Input
2
ssh
hhs
Output
6
Explanation
The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.