2018组队训练赛第二十二场--省赛前最后一水.CF

这篇博客详细介绍了2018年组队训练赛第二十二场比赛的情况,该赛事是省级比赛前的最后一场实战演练。重点探讨了比赛中涉及的贪心算法和动态规划问题,提供了题目描述、输入输出格式以及样例,为参赛者提供了解题思路和参考。
摘要由CSDN通过智能技术生成

问题 K: CF

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

题目描述

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
考点:贪心+动态规划
#include<bits/stdc++.h>
using namespace std;
struct node{
    int a,b,c;
    double f;
}x[2009];
int dp[5009];
bool cmp(struct node a,struct node b){
    return a.f>b.f;
}
int main(){
    int n,t;
    cin>>n>>t;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)  cin>>x[i].a;
    for(int i=1;i<=n;i++)  cin>>x[i].b;
    for(int i=1;i<=n;i++)  cin>>x[i].c;
    for(int i=1;i<=n;i++)
        x[i].f=1.0*x[i].b/x[i].c;
    sort(x+1,x+n+1,cmp);
    int mix=0;
    for(int i=1;i<=n;i++){
        for(int j=t;j>=x[i].c;j--){
            dp[j]=max(dp[j],dp[j-x[i].c]+x[i].a-x[i].b*j);
            mix=max(dp[j],mix);
        }
    }
    cout<<mix<<endl;;
    return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值