Codeforces Round #156 (Div. 2)---A. Greg's Workout
2016-01-28 15:49
399 查看
Greg's Workout
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 ai times.
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.
Sample test(s)
input
output
input
output
input
output
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.
解题思路:水题。把全部数据扫一遍,直接计算每种锻炼相应的总次数,找出三者中的最大值所相应的锻炼种类。
AC代码:
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 ai times.
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.
Sample test(s)
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.
解题思路:水题。把全部数据扫一遍,直接计算每种锻炼相应的总次数,找出三者中的最大值所相应的锻炼种类。
AC代码:
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main(){ // freopen("in.txt","r",stdin); int n, k; while(cin>>n){ int x = 0, xx = 0, xxx = 0; for(int i=1; i<=n; i++){ cin>>k; if(i%3==1) x += k; else if(i%3==2) xx += k; else xxx += k; } int t = max(x, max(xx, xxx)); if(x == t) cout<<"chest"<<endl; else if(xx == t) cout<<"biceps"<<endl; else cout<<"back"<<endl; } return 0; }
相关文章推荐
- 定位之初解
- JDK扩展DCEVM让WEB程序完全不重启调试
- 跟我一起学习ASP.NET 4.5 MVC4.0(四)
- 【cocos2dx】状态机应用场景及原理
- node-gyp 设置 Proxy
- 经验风险与结构风险
- 用IIS配置反向代理
- 两个栈模拟队列
- 14.Adding Frontend Files to your Module
- 初试微信订阅号有感
- 跟我一起学习ASP.NET 4.5 MVC4.0(三)
- 有关inode知识的小结:学会给阶段性的知识做小结是学好linux运维的好习惯
- Flask和@app.route(2)
- unity 项目build 的时候后报错An asset is marked with HideFlags.DontSave but is included in the build:
- Swift 基本知识点之六枚举
- 排队
- java源码
- 《彻底搞定C指针》文档整理
- 跟我一起学习ASP.NET 4.5 MVC4.0(二)
- 3.Swift 中的where