传送门:点击打开链接
题目描述
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;
typedef long long LL;
struct node
{
int a,c,d;
double m;
} q[2005];
bool cmp(node x,node y)
{
if(x.m==y.m)
return x.c<y.c;
return x.m>y.m;
}
int dp[5005];
int main()
{
int i,n,t;
cin>>n>>t;
for(i=1; i<=n; i++) scanf("%d",&q[i].a);
for(i=1; i<=n; i++) scanf("%d",&q[i].d);
for(i=1; i<=n; i++)
{
scanf("%d",&q[i].c);
q[i].m=q[i].d*1.0/q[i].c;
}
sort(q+1,q+1+n,cmp);
int maxx=0;
for(int i=1; i<=n; i++)
for(int j=t; j>=q[i].c; j--)
{
dp[j]=max(dp[j],dp[j-q[i].c]+q[i].a-q[i].d*j);
maxx=max(dp[j],maxx);
}
printf("%d\n",maxx);
return 0;
}
本文介绍了一道关于比赛策略的问题,通过分析题目特点,采用先做失分最多且用时最短的题目策略,并结合01背包问题解决方法,实现最大化得分目标。
1万+

被折叠的 条评论
为什么被折叠?



