第十五届浙江大学宁波理工学院程序设计大赛_L_The Last Stand

传送门

思路:
dp转移方程: dp[i]=max(dp[i],dp[j]+p[j].val+(p[i].id-p[j].id)*p[j].del);

#include
#define debug(a) cout << #a << " " << a << endl
#define lnn putchar('\n')
#define see putchar(' ')
#define LL long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-6
const int N=1e4+7;
using namespace std;
inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x)
{
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
struct node{
    LL id;
    LL val,del;
}p[N];
int cnt=0;
LL dp[1005];
int main ()
{
    //yyy_3y
    //freopen("1.in","r",stdin);
    int T; scanf("%d",&T);
    while(T--){
        memset(dp,0,sizeof dp);
        LL n,m,h; scanf("%lld%lld%lld",&n,&m,&h);
        for(int i=1;i<=n;i++){
            scanf("%lld%lld%lld",&p[i].id,&p[i].val,&p[i].del);
        }
        p[n+1].id=m;
        p[n+1].val=0;
        p[n+1].del=0;
        dp[0]=h;
        for(int i=1;i<=n+1;i++){
            for(int j=0;j

你可能感兴趣的:(DP)