CF_dp

CF

Time Limit: 1000 msMemory Limit: 65536 KiB
Problem Description

LYD loves codeforces since there are many Russian contests. In an contest lasting for T minutes there are n problems, and for the ith problem you can get aiditi points, where ai indicates the initial points, di indicates the points decreased per minute (count from the beginning of the contest), and ti stands for the passed minutes when you solved the problem (count from the begining of the contest).
Now you know LYD can solve the ith problem in ci minutes. He can't perform as a multi-core processor, so he can think of only one problem at a moment. Can you help him get as many points as he can?

Input

The first line contains two integers n,T(0≤n≤2000,0≤T≤5000).
The second line contains n integers a1,a2,..,an(0<ai≤6000).
The third line contains n integers d1,d2,..,dn(0<di≤50).
The forth line contains n integers c1,c2,..,cn(0<ci≤400).

Output

Output an integer in a single line, indicating the maximum points LYD can get.

Sample Input
3 10
100 200 250
5 6 7
2 4 10
Sample Output
254
Hint
Source
“浪潮杯”山东省第八届ACM大学生程序设计竞赛(感谢青岛科技大学)

#include<bits/stdc++.h>
using namespace std;

const int N(2000+10);

struct AA{
    int a,d,t;
}a[N];

#define f(i,n) for(i=0;i<n;i++)

bool cmp(AA a,AA b){
    return a.t*b.d<a.d*b.t;
}

int dp[5000+10];


int main(){
    //freopen("in.txt","r",stdin);
    int n,T;
    cin>>n>>T;
    int i;
    f(i,n)cin>>a[i].a;
    f(i,n)cin>>a[i].d;
    f(i,n)cin>>a[i].t;
    sort(a,a+n,cmp);
    int mm=0;
    f(i,n)
    for(int j=T;j>=a[i].t;j--){
           dp[j]=max(dp[j],dp[j-a[i].t]+a[i].a-a[i].d*j);
        mm=max(dp[j],mm);
    }

    cout<<mm<<endl;

//    fclose(stdin);

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值