热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_52668597
踏过山河,踏过海
4 年前
trueweixin_52668597

蓝桥杯_答疑
最佳答案!
#include <iostream>
#include <algorithm>
#define N 1010
using namespace std;

typedef struct student{
int s,a,e;
int t1,t2;//t1为s+a,t2为s+a+e
}stu;

bool cmp(stu a,stu b){
return a.t2<b.t2;//根据每个学生花费的总时间来排序
}

int main()
{
int n;
stu st[N];
cin>>n;//几个人

for(int i=1;i<=n;i++){
cin>>st[i].s>>st[i].a>>st[i].e;//每个人花费的时间
st[i].t1=st[i].a+st[i].s;//答疑的时间
st[i].t2=st[i].t1+st[i].e;//答疑的时间+收拾东西的时间
}

sort(st+1,st+n+1,cmp);

long long sum=0,s=0;
for(int i=1;i<=n;i++){
sum += st[i].t1+s;
s += st[i].t2;
}

cout<<sum<<endl;

return 0;
}

保持热爱共赴山海
CSDN App 扫码分享
分享
1
点赞
打赏
  • 复制链接
  • 举报
下一条动态
立即登录