A12899 | Stones
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice is playing with some stones.
Now there are three numbered heaps of stones. The first of them contains $a$ stones, the second of them contains $b$ stones and the third of them contains $c$ stones.
Each time she can do one of two operations:
1. take one stone from the first heap and two stones from the second heap (this operation can be done only if the first heap contains at least one stone and the second heap contains at least two stones);
2. take one stone from the second heap and two stones from the third heap (this operation can be done only if the second heap contains at least one stone and the third heap contains at least two stones).
She wants to get the maximum number of stones, but she doesn't know what to do. Initially, she has $0$ stones. Can you help her?
Now there are three numbered heaps of stones. The first of them contains $a$ stones, the second of them contains $b$ stones and the third of them contains $c$ stones.
Each time she can do one of two operations:
1. take one stone from the first heap and two stones from the second heap (this operation can be done only if the first heap contains at least one stone and the second heap contains at least two stones);
2. take one stone from the second heap and two stones from the third heap (this operation can be done only if the second heap contains at least one stone and the third heap contains at least two stones).
She wants to get the maximum number of stones, but she doesn't know what to do. Initially, she has $0$ stones. Can you help her?
输入格式
The first line contains one integer $t$ ( $1 \leq t \leq 100$ ) — the number of test cases. Next $t$ lines describe test cases in the following format:
Line contains three non-negative integers $a$ , $b$ and $c$ , separated by spaces ( $0 \leq a,b,c \leq 100$ ) — the number of stones in the first, the second and the third heap, respectively.
In hacks it is allowed to use only one test case in the input, so $t = 1$ should be satisfied.
Line contains three non-negative integers $a$ , $b$ and $c$ , separated by spaces ( $0 \leq a,b,c \leq 100$ ) — the number of stones in the first, the second and the third heap, respectively.
In hacks it is allowed to use only one test case in the input, so $t = 1$ should be satisfied.
输出格式
Print $t$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer — the maximum possible number of stones that Alice can take after making some operations.
输入输出样例
输入 #1
3 3 4 5 1 0 5 5 3 2
输出 #1
9 0 6
For the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones, that Alice will take is $9$ . It is impossible to make some operations to take more than $9$ stones, so the answer is $9$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted