记录编号 |
83788 |
评测结果 |
A |
题目名称 |
排队接水 |
最终得分 |
100 |
用户昵称 |
ch3coooh |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.000 s |
提交时间 |
2013-12-06 18:28:17 |
内存使用 |
0.29 MiB |
显示代码纯文本
#include<cstdio>
using namespace std;
struct p
{
int id;
int time;
}people[20];
int main()
{
freopen("jieshui.in","r",stdin);
freopen("jieshui.out","w",stdout);
int i,n,j;
scanf("%d",&n);
for(i=0;i<n;i++)
{
people[i].id=i+1;
scanf("%d",&people[i].time);
}
for(i=0;i<n;i++)
for(j=i;j<n;j++)
if(people[i].time>people[j].time)
{
int cup=people[i].time;
people[i].time=people[j].time;
people[j].time=cup;
cup=people[i].id;
people[i].id=people[j].id;
people[j].id=cup;
}
int sum=0;
for(i=0;i<n;i++)
{
printf("%d",people[i].id);
printf("%c",' ');
for(j=0;j<i;j++)
sum+=people[j].time;
}
double t=(double)sum/(double)n;
printf("\n%.2lf",t);
return 0;
}