山东省第八届ACM省赛.CF

问题 K: CF

时间限制: 1 Sec   内存限制: 128 MB
提交: 125   解决: 29
[ 提交][ 状态][ 讨论版][命题人: 外部导入]

题目描述

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 ai−di∗ti 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?

输入

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 an integer in a single line, indicating the maximum points LYD can get.

样例输入

3 10
100 200 250
5 6 7
2 4 10

样例输出

254
考点:动态规划,01背包
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

struct node{
    int score,de,time;
    double en;
}a[2009];
bool cmp(struct node a,struct node b){
    return a.en>b.en;
}
int dp[5009];
int main(){
    int n,T;
    memset(a,0,sizeof(0));
    while(cin>>n>>T){
        for(int i=0;i<n;i++) cin>>a[i].score;
        for(int i=0;i<n;i++) cin>>a[i].de;
        for(int i=0;i<n;i++) cin>>a[i].time,a[i].en=1.0*a[i].de/a[i].time;
        sort(a,a+n,cmp);
        int ans=0;
        for(int i=0;i<n;i++)
        for(int j=T;j>=a[i].time;j--){
            dp[j]=max(dp[j],dp[j-a[i].time]+a[i].score-a[i].de*j);ans=max(dp[j],ans);
        }
        cout<<ans<<endl;
    }
}



猜你喜欢

转载自blog.csdn.net/xxxxxm1/article/details/80288646