A11694 | Mancala
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.
Initially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.
Note that the counter-clockwise order means if the player takes the stones from hole $i$ , he will put one stone in the $(i+1)$ -th hole, then in the $(i+2)$ -th, etc. If he puts a stone in the $14$ -th hole, the next one will be put in the first hole.
After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.
Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.
Initially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.
Note that the counter-clockwise order means if the player takes the stones from hole $i$ , he will put one stone in the $(i+1)$ -th hole, then in the $(i+2)$ -th, etc. If he puts a stone in the $14$ -th hole, the next one will be put in the first hole.
After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.
Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.
输入格式
The only line contains 14 integers $a_1, a_2, \ldots, a_{14}$ ( $0 \leq a_i \leq 10^9$ ) — the number of stones in each hole.
It is guaranteed that for any $i$ ( $1\leq i \leq 14$ ) $a_i$ is either zero or odd, and there is at least one stone in the board.
It is guaranteed that for any $i$ ( $1\leq i \leq 14$ ) $a_i$ is either zero or odd, and there is at least one stone in the board.
输出格式
Output one integer, the maximum possible score after one move.
输入输出样例
输入 #1
0 1 1 0 0 0 0 0 0 7 0 0 0 0
输出 #1
4
输入 #2
5 1 1 1 1 0 0 0 0 0 0 0 0 0
输出 #2
8
In the first test case the board after the move from the hole with $7$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $4$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted