CF1236A.Stones
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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:
- 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);
- 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?
爱丽丝正在玩一些石头。
现在有三堆编号的石头。第一堆包含 a 颗石头,第二堆包含 b 颗石头,第三堆包含 c 颗石头。
每次她可以执行以下两种操作之一:
- 从第一堆取走 1 颗石头,并从第二堆取走 2 颗石头(该操作仅在第一堆至少有 1 颗石头且第二堆至少有 2 颗石头时才能进行);
- 从第二堆取走 1 颗石头,并从第三堆取走 2 颗石头(该操作仅在第二堆至少有 1 颗石头且第三堆至少有 2 颗石头时才能进行)。
她希望获得尽可能多的石头,但不知道该如何操作。初始时,她手中有 0 颗石头。你能帮帮她吗?
输入格式
The first line contains one integer t (1≤t≤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≤a,b,c≤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.
第一行包含一个整数 t(1≤t≤100)—— 测试用例的数量。接下来的 t 行以如下格式描述各个测试用例:
每行包含三个由空格分隔的非负整数 a、b 和 c(0≤a,b,c≤100)—— 分别表示第一堆、第二堆和第三堆中的石子数量。
在 hack 中,输入中只允许使用一个测试用例,因此必须满足 t=1。
输出格式
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.
输出 t 行,按输入中测试用例的相同顺序给出各测试用例的答案。每个测试用例的答案为一个整数——即 Alice 在执行若干操作后能够取走的石头的最大可能数量。
输入输出样例
输入#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.
对于第一组测试数据中的第一个测试用例,Alice 可以从第二堆中取走两颗石子,从第三堆中取走四颗石子,执行第二次操作共两次;然后她可以从第一堆中取走一颗石子,从第二堆中取走两颗石子,执行第一次操作共一次。Alice 总共取走的石子数为 9。不存在任何操作方式能取走超过 9 颗石子,因此答案为 9。
输入解题思路,AI测评打分。不知道怎么写?