Problem G
race for two or more teams of runners. Each member of a team runs
one section of the race. Your task is to help to evaluate the
results of a relay race.
You have to process several teams. For each team you are given a
list with the running times for every section of the race. You are
to compute the average time per kilometer over the whole distance.
That's easy, isn't it?
So if you like the fun and challenge competing at this contest,
perhaps you like a relay race, too. Students from Ulm participated
e.g. at the "SOLA" relay in Zurich, Switzerland. For more
information visit http://www.sola.asvz.ethz.ch/ after the contest
is over.
of the input specifies the number of sections n followed by the
total distance of the relay d in kilometers. You may safely assume
that 1 <= n <= 20 and 0.0 < d < 200.0. Every following
line gives information about one team: the team number t (an
integer, right-justified in a field of width 3) is followed by the
n results for each section, separated by a single space. These
running times are given in the format "h:mm:ss" with integer
numbers for the hours, minutes and seconds, respectively. In the
special case of a runner being disqualified, the running time will
be denoted by "-:--:--". Finally, the data on every line is
terminated by a newline character. Input is terminated by
EOF.
output exactly one line giving the team's number t right aligned in
a field of width 3, and the average time for this team rounded to
whole seconds in the format "m:ss". If at least one of the team's
runners has been disqualified, output "-" instead. Adhere to the
sample output for the exact format of presentation.
12.5
0:25:01
-:--:--
0:41:35
min/km
min/km
15MS)
#include
using namespace std;
int main()
{
//freopen("in.txt", "r", stdin);
int
n,t,h,m,s,time_s;
double
d;
bool
flag;
scanf("%d
%lf",&n,&d);
while(cin>>t)
{
flag=1;
time_s=0;
for(int i=0;i
{
char str;
cin>>str;
if(str=='-')
{
cin>>str>>str>>str>>str>>str>>str;
flag=0;
continue;
}
else
{
scanf("%*c%d%*c%d",&m,&s);//%*c的意思就是跳过这个不输入了
time_s+=(s+m*60+(str-'0')*3600);
}
}
if(!flag)
printf("=: -\n", t);
else
{
int ave=1.0*time_s/d+0.5;
m=ave/60;
s=ave`;
printf("=: %d:d min/km\n", t, m, s);
}
}
return
0;
}
Problem G的更多相关文章
- 实验9:Problem G: 克隆人来了!
想要输出""的话: cout<<"A person whose name is \""<<name<<" ...
- 实验12:Problem G: 强悍的矩阵运算来了
这个题目主要是乘法运算符的重载,卡了我好久,矩阵的乘法用3个嵌套的for循环进行,要分清楚矩阵的乘法结果是第一个矩阵的行,第二个矩阵的列所组成的矩阵. 重载+,*运算符时,可以在参数列表中传两个矩阵引 ...
- 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem G: Check The Check(模拟国际象棋)
Problem G: Check The Check Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 10 Solved: 3[Submit][Statu ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem G
Problem G Good Teacher I want to be a good teacher, so at least I need to remember all the student n ...
- 【贪心+中位数】【新生赛3 1007题】 Problem G (K)
Problem G Time Limit : 4000/2000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Sub ...
- Problem G: If We Were a Child Again
Problem G: If We Were a Child AgainTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solved: 14[Submi ...
- Problem G: Keywords Search
Problem G: Keywords SearchTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 10 Solved: 6[Submit][Status] ...
- BZOJ4977 八月月赛 Problem G 跳伞求生 set 贪心
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ4977 - 八月月赛 Problem G 题意 小明组建了一支由n名玩家组成的战队,编号依次为1到n ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem G. k-palindrome dp
Problem G. k-palindrome 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022 ...
- ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)
题目链接 ZOJ Monthly, March 2018 Problem G 题意 给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...
随机推荐
- GCD之并行串行区别
1.用户自定义线程队列,创建时很容易创建 注意创建时的第一个参数:标记值,方便调试查看 1 2 dispatch_queue_t serialqueue=dispatch_queue_create(& ...
- 转换时间对象和字符串对象&添加时间
/* *基本思路,将字符串时间转化为时间对象,通过毫秒数来加减时间,然后在转化为字符串输出 */ //转化字符时间yy-mm-dd hh:mm:ss 为时间对象 使用split进行字符串的分割,取 ...
- 初识oracle存储过程
参见:http://www.cnblogs.com/linjiqin/archive/2011/04/16/2018411.html 1.存储过程的语法结构: CREATE OR REPLACE PR ...
- React的组件用法
React.createClass() 中文翻译 https://discountry.github.io/react/3.4K ( https://doc.react-china.org868 ) ...
- spring jar包
org.springframework.aop- 3.0.0.RELEASE--------------------Spring的面向切面编程,提供AOP(面向切面编程)实现 org.springfr ...
- 51 nod 1097 拼成最小的数 思路:字符串排序
题目: 思路:1.以字符串输入这些整数. 2.对这些字符串排序,排序规则为尽量让能让结果变小的靠前. 代码中有注释,不懂的欢迎在博客中评论问我. 代码: #include <bits\stdc+ ...
- 应试记录2(没有转载标注,NOIP2016复赛过后自动删除)
#include<stdio.h> #include<string.h> int main() { ]; memset(a, , sizeof(a)); ;i<=;i++ ...
- C#无限分级实现,前端WEB页面接收,后台提供层级Json数据
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Te ...
- c#(asp.net) 多线程示例,用于同时处理多个任务
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- zookeeper curator处理会话过期session expired
本文介绍在使用curator框架的时候如何handle session expire. 1.什么是zookeeper的会话过期? 一般来说,我们使用zookeeper是集群形式,如下图,client和 ...