#P6713. [CCO 2018] Geese vs. Hawks
[CCO 2018] Geese vs. Hawks
Description
Troy and JP are hockey fans. In this season, each hockey team plays games. Each game is played between two teams, and the team with the higher score wins. There are no ties.
Troy’s favorite team is the Waterloo Geese, and he recorded the result of each game for this team. The results are written as a string . If the Geese won the -th game, then ; otherwise, . He also recorded that in the -th game, they scored points.
JP’s favorite team is the Laurier Golden Hawks, and he also recorded the result of each game for this team. The results are written as a string . If the Golden Hawks won the -th game, then ; otherwise, . He also recorded that in the -th game, they scored points.
Troy and JP recorded, in order, the results and scores of every game played by their favorite teams.
A crosstown derby means a game between the Waterloo Geese and the Laurier Golden Hawks (because both teams’ home arenas are in Waterloo). Since Troy and JP did not record the opponents in their favorite teams’ games, they cannot determine whether any crosstown derbies happened, nor which games were crosstown derbies. They want to know, based on the information they recorded, what the maximum possible total sum of points scored by both teams across all crosstown derbies is.
Input Format
The first line contains an integer .
The second line contains a string of length , and it is guaranteed that contains only and .
The third line contains integers .
The fourth line contains a string of length , and it is guaranteed that contains only and .
The fifth line contains integers .
Output Format
Output one line containing one integer, meaning the maximum possible total sum of points scored by both teams across all crosstown derbies.
1
W
2
W
3
0
4
WLLW
1 2 3 4
LWWL
6 5 3 2
14
Hint
Sample Explanation
Sample 1 Explanation
Because both teams won their games, there cannot be any crosstown derbies.
Sample 2 Explanation
The 4th game played by each team could be a crosstown derby: the Geese scored points and the Golden Hawks scored points. The Geese’s 3rd game and the Golden Hawks’ 2nd game could also be a crosstown derby: the Golden Hawks scored points and the Geese scored points. The total sum of points is , and this is the maximum possible total.
Note that the Geese won their 1st game and scored point, so that game cannot be against the Golden Hawks, because the Golden Hawks have no game where they scored points. Also, the Golden Hawks’ 1st game cannot be a crosstown derby either, because the Golden Hawks lost their 1st game and scored points, and the Geese never had a game where they scored at least points.
Constraints
For of the testdata, it is guaranteed that , , W, L.
- Subtask 1 ( points): is guaranteed.
- Subtask 2 ( points): No additional constraints.
Notes
This problem is translated from Canadian Computing Olympiad 2020 Day 1 T1 Geese vs. Hawks.
Translated by ChatGPT 5
京公网安备 11011102002149号