热门

最新

红包

立Flag

投票

同城

我的

发布
chairon
chairon
4 年前
truechairon

原来CSDN还能发“朋友圈”……

研究生的日常
CSDN App 扫码分享
分享
评论
3
打赏
  • 复制链接
  • 举报
下一条:
蓝桥杯_答疑最佳答案!#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;}
立即登录