#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.
题目大意
【题目描述】
庞教授邀请了 位教授参加他的宴会。教授们坐在一个圆桌周围。对于所有 ,从 到 ,教授 坐在教授 和 旁边。
庞教授准备了 道菜。桌子上有 个位置。位置 在教授 的前面。教授 只能接触到放在位置 、 和 处的菜。庞教授将在每个位置上放置一道菜。
在这些菜中,有 道是辣的, 道是不辣的。有些(可能为 )教授不能吃辣的食物。如果一位教授可以吃辣的食物,他/她的满意度水平是他/她可以接触到的菜的数量(无论是辣的还是不辣的)。如果一位教授不能吃辣的食物,他/她的满意度水平是他/她可以接触到的不辣的菜的数量。
庞教授知道每位教授是否可以吃辣的食物。请帮助他安排桌子上的菜,使得所有教授的满意度水平之和最大化。输出最大的总和。
【输入格式】
第一行包含两个整数 ()。
第二行包含 个整数 。 是 或 。 表示教授 可以吃辣的食物。 表示教授 不能吃辣的食物。
【输出格式】
输出一行一个整数,表示答案。
翻译来自于:ChatGPT
5 2
1 0 1 0 1
13