蓝桥杯_答疑最佳答案!#include <iostream>#include <algorithm>#define N 1010using 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;}