马拉松接力赛

来源:互联网 发布:2017全球社交网络排名 编辑:程序博客网 时间:2024/05/17 00:52
#include<bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int a[5][11],temp[5];
int t[5][11],Min,tag,sum;
int main()
{
for(int i=0;i<5;i++)
for(int j=1;j<11;j++)
{
cin>>a[i][j];
t[i][j]=a[i][j]-a[i][j-1];
}
temp[0]=temp[1]=temp[2]=temp[3]=temp[4]=1;
for(int i=0;i<20;i++)
{
Min=INF;
for(int j=0;j<5;j++)
{
if(t[j][temp[j]+1]<Min&&temp[j]+1<=10)
{
tag=j;
Min=t[j][temp[j]+1];
}
}
temp[tag]++;
}
sum=0;
for(int i=0;i<5;i++)
sum+=a[i][temp[i]];
cout<<sum<<endl;
cout<<temp[0]<<" "<<temp[1]<<" "<<temp[2]<<" "<<temp[3]<<" "<<temp[4]<<endl;
return 0;
}
1 0
原创粉丝点击