提交时间:2022-10-04 11:32:06
运行 ID: 57510
#include<bits/stdc++.h> using namespace std; int n,l,m,m_s,s_m,s,t[100005],p[100005],f[100005],i,j,ksd=0,ksd1,jgd,tjs; int main(){ cin>>n>>l>>m>>m_s>>s_m>>s; for(i=1;i<=n;i++)scanf("%d %d %d",&t[i],&p[i],&f[i]); for(i=1;i<=n;i++){ ksd1=-1000000000; for(j=t[i]+p[i]-t[i-1]-p[i-1];j<=t[i]+p[i];j++){ if(j<2*l)jgd=-j*m; else jgd=max((j-2*l)*s-l*(m_s+s_m),-(j)*m); jgd+=f[i]*(t[i]+p[i]-j); if(jgd>ksd1){ ksd1=jgd; tjs=j; } } ksd+=ksd1; t[i]=tjs; } printf("%d\n",ksd); }