山东省第八届ACM省赛 K 题(CF)
2017-05-11 19:38
302 查看
Problem Description
![](http://acm.sdut.edu.cn/image/3903.png)
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?
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.Example Input
3 10 100 200 250 5 6 7 2 4 10
Example Output
254
题意:LYD要打CF,一共n道题,t单位时间,每道题都有初始分数a,每单位时间减的分数d和做出这道题需要多长时间c,求最大的得分;
思路:01背包,先把每道题的d/c按从大到小排序,先取减分最快的,做一边01背包就行了;
ps:后悔了,没想到这道题这么简单,当时比赛的时候没做。。。。
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #define INF 0x3f3f3f3f #define maxn 2010 using namespace std; int n,t; int dp[5050]; struct edge { int a,d,c; double f; }; bool cmp(edge x,edge y) { return x.f>y.f; } edge g[maxn]; int main() { memset(dp,0,sizeof(dp)); scanf("%d%d",&n,&t); for(int i=0; i<n; i++) { scanf("%d",&g[i].a); } for(int i=0; i<n; i++) { scanf("%d",&g[i].d); } for(int i=0; i<n; i++) { scanf("%d",&g[i].c); g[i].f=1.0*g[i].d/g[i].c; } sort(g,g+n,cmp); for(int i=0; i<n; i++) { for(int j=t; j>=g[i].c; j--) { dp[j]=max(dp[j],dp[j-g[i].c]+g[i].a-g[i].d*j); } } int MAX=-INF; for(int i=0; i<=t; i++) { if(MAX<dp[i]) MAX=dp[i]; } cout<<MAX<<endl; return 0; }
相关文章推荐
- 山东省第八届ACM省赛 K 题 CF 解答(未完,待续)
- 山东省第八届ACM省赛 K 题 CF (排序01背包)
- 山东省第八届 ACM 省赛 CF (01背包、水)
- 2017山东省第八届ACM省赛 fireworks(杨辉三角 + 逆元)
- 2017 年山东省第八届ACM省赛总结
- 山东省第八届acm省赛 Return of the Nim
- SDUT 3895 (山东省第八届ACM省赛C题) fireworks 杨辉三角+乘法逆元
- 山东省第八届acm省赛D题HEX(组合数学)
- 山东省第八届acm省赛C题 巨坑
- CF----思维排序+01背包 山东省第八届省赛K题
- 山东省第八届acm省赛 HEX
- 山东省第八届ACM省赛 G 题(sum of power)
- 山东省第八届acm省赛B题 打表找规律
- 山东省第八届ACM省赛C firework
- 山东省第八届ACM省赛A题
- 2017山东省第八届ACM省赛 D. HEX(组合数学)
- 山东省第八届ACM省赛 D.HEX
- [置顶] 2017年山东省第八届acm省赛总结
- "浪潮杯”山东省第八届ACM大学生程序设计竞赛 CF
- 山东省第八届ACM省赛 I 题(Parity check)