codeforces
发布时间: 2017年5月13日 22:40 最后更新: 2017年5月14日 16:39 时间限制: 1000ms 内存限制: 128M
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 beginning 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 ashe 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
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct node{
int score;
int d;
int t;
double op;
bool operator <(const node nd)const
{
return op < nd.op;
}
};
node a[100005];
int cash[50000];
int dp[100050];
int main()
{
int n,T;
scanf("%d%d",&n,&T);
for(int i = 1; i <= n; i++)
scanf("%d",&a[i].score);
for(int i = 1; i <= n; i++)
scanf("%d",&a[i].d);
for(int i = 1; i <= n; i++)
{
scanf("%d",&a[i].t);
a[i].op = a[i].t*1.0 / a[i].d;
}
sort(a+1,a+1+n);
int max_ = -1;
for(int i = 1; i <= n; i++)
{
for(int j = T; j >= a[i].t; j--)
{
dp[j] = max(dp[j],dp[j-a[i].t] + max(0,a[i].score - j*a[i].d));
max_ = max(max_,dp[j]);
}
}
printf("%d\n",max_);
return 0;
}
CodeForces竞赛策略算法
本文介绍了一种解决CodeForces竞赛中动态调整分数问题的算法。通过计算每道题目的时间价值比来确定解题顺序,并采用0-1背包算法优化得分策略。
316

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



