#P9728. [EC Final 2022] Dining Professors
[EC Final 2022] Dining Professors
题目描述
Prof. Pang invited professors to his banquet. The professors sit at a round table. For all from to , professor sits adjacent to professor and .
Prof. Pang prepared dishes. There are positions on the table. Position is in front of professor . Professor can access only the dishes placed at positions , , and . Prof. Pang will place exactly one dish at each position.
Among the dishes, of them are spicy and of them are not spicy. Some (possibly ) professors are unable to have spicy food. If a professor can have spicy food, his/her satisfaction level is the number of dishes (no matter spicy or not) he/she can access. If a professor cannot have spicy food, his/her satisfaction level is the number of not spicy dishes he/she can access.
Prof. Pang knows whether each professor can have spicy food or not. Please help him to arrange the dishes on the table so that the sum of satisfaction levels over all the professors is maximized. Output the maximum sum.
输入格式
The first line contains two integers ().
The second line contains integers . is or . means professor can have spicy food. means professor cannot have spicy food.
输出格式
Output one integer representing the answer in one line.
5 2
1 0 1 0 1
13