概述
题干:
Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was n integers a1, a2, ..., an. These numbers mean that Greg needs to do exactly n exercises today. Besides, Greg should repeat the i-th in order exercise aitimes.
Greg now only does three types of exercises: "chest" exercises, "biceps" exercises and "back" exercises. Besides, his training is cyclic, that is, the first exercise he does is a "chest" one, the second one is "biceps", the third one is "back", the fourth one is "chest", the fifth one is "biceps", and so on to the n-th exercise.
Now Greg wonders, which muscle will get the most exercise during his training. We know that the exercise Greg repeats the maximum number of times, trains the corresponding muscle the most. Help Greg, determine which muscle will get the most training.
Input
The first line contains integer n (1 ≤ n ≤ 20). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 25) — the number of times Greg repeats the exercises.
Output
Print word "chest" (without the quotes), if the chest gets the most exercise, "biceps" (without the quotes), if the biceps gets the most exercise and print "back" (without the quotes) if the back gets the most exercise.
It is guaranteed that the input is such that the answer to the problem is unambiguous.
Examples
Input
2 2 8
Output
biceps
Input
3 5 1 10
Output
back
Input
7 3 3 2 7 9 6 8
Output
chest
Note
In the first sample Greg does 2 chest, 8 biceps and zero back exercises, so the biceps gets the most exercises.
In the second sample Greg does 5 chest, 1 biceps and 10 back exercises, so the back gets the most exercises.
In the third sample Greg does 18 chest, 12 biceps and 8 back exercises, so the chest gets the most exercise.
题目大意:
一个人有n个回合的三个项目要训练,每个回合ai次,现在告诉你第一个回合先练“chest”,第二个回合练"biceps",第三个回合练"back",第四个回合又练“chest”,,以此类推。现在告诉你每个回合的练习次数,问你哪个项目练的次数最多。
解题报告:
直接暴力,,,注意取模的运用会简化代码,,,但是别忘了要从0开始读入、、
AC代码:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e6 + 5;
ll n,tmp;
ll bk[20];
int main()
{
cin>>n;
for(int i = 0; i<n; i++) {
scanf("%lld",&tmp);
bk[i%3]+=tmp;
}
if(bk[0] > bk[1] && bk[0] > bk[2]) {
printf("chest");
}
else if(bk[1] > bk[0] && bk[1] > bk[2]) {
printf("biceps");
}
else printf("back");
return 0 ;
}
总结:
一个小坑,,注意一下就好了,,取模的时候,,需要从0开始读入
最后
以上就是谦让太阳为你收集整理的【CodeForces - 255A】Greg's Workout (水题)的全部内容,希望文章能够帮你解决【CodeForces - 255A】Greg's Workout (水题)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复