山东生第八届acm省赛 cf
来源:互联网 发布:传奇霸业魔血符数据 编辑:程序博客网 时间:2024/04/30 06:52
CF
Problem Description
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∗tipoints, 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 10100 200 2505 6 72 4 10
Example Output
254
Hint
Author
题意:主角打cf比赛 他有n道题 且他一共有t的时间来做这些题 a1到an是这n道题做出来后相应的分数 d1到dn是这n到题从开始到做出花费的时间里每分钟要扣除的分数 c1到cn是这每道题做出需要花费的时间 要求算出他所能湖的的最大分数
这道题在比赛的时候作为最后时间内尝试的题目 用了10分钟套了一个01背包的板子 当然肯定错了 后来补题又看到了这道题 可是还是想不出来解决的办法 这道题和普通的01背包区别在多了一个罚时 可是在规划的比较公式内得分减去罚时也不对 后来百度 看见百度上说在进行规划之前要先进行对题目的优先顺序排序 。
具体的排序规则:
假设有两个题, 第一个题 a.c a.d 第二个题 b.c b.d 两种顺序减得分分别是 a.c*a.d+(b.c+a.c)*b.d 〈 b.c*b.d+(b.c+a.c)*a.d 化简就是a.c/a.d < b.c/b.d
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e6 + 5;
int dp[maxn]; //开一个很大的dp数组 用来动态规划存储需比较的数据
struct node
{
int d, c, t; //定义一个结构体a d为本题分数 c为罚时扣分 t为题目需要花费的时间
double f; //f为c/d 用来排序的要素
}a[2000+5];
int cmp(node a, node b)
{
return a.f < b.f; //用来排序f的函数
}
int main()
{
int n, t;
while(~scanf("%d%d", &n, &t))
{
memset(dp, 0, sizeof(dp));
for(int i = 1; i <= n; i++) //开始输入所有的数据
scanf("%d", &a[i].t);
for(int i = 1; i <= n; i++)
scanf("%d", &a[i].d);
for(int i = 1; i <= n; i++)
scanf("%d", &a[i].c), a[i].f = a[i].c*1.0 / a[i].d; //f的值
sort(a+1, a+1+n, cmp); //根据f进行排序
int maxx = 0; //定义一个最小值 用于后面的比较 然后存值
for(int i = 1; i <= n; i++) //遍历题目
{
for(int v = t; v >= a[i].c; v--) //规划可用的做题时间
{
dp[v] = max(dp[v], dp[v-a[i].c]+a[i].t-a[i].d*v); //dp的比较过程
maxx = max(dp[v], maxx); //在过程中取最大值,因为不一定t分钟都用上 因为可能存在你做出一道题得到的分数比这道题的罚时分少 所以不做这道题时的分数更多
}
}
printf("%d\n", maxx);
}
return 0;
}
CF
Problem Description
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∗tipoints, 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 10100 200 2505 6 72 4 10
Example Output
254
Hint
Author
- 山东生第八届acm省赛 cf
- 第八届山东acm省赛 C题 fireworks (组合数)
- 山东第八届ACM省赛总结
- 第八届山东acm省赛总结
- 山东省第八届 ACM 省赛 CF (01背包、水)
- 山东省第八届ACM省赛 K 题(CF)
- 山东省第八届acm省赛K题 CF
- SDUT 3893 威佐夫+nim博弈(第八届山东ACM省赛A题)
- 山东理工大学第八届ACM校赛——活动选择
- 山东理工大学第八届ACM校赛——选拔忧虑
- 山东第八届acm大赛F题quadratic equation,山东理工oj 3898
- 第三届山东ACM省赛 Pixel density
- 第七届山东ACM省赛G题
- 第二届山东ACM省赛 Crack Mathmen
- 2017 山东acm省赛
- 山东省第八届ACM省赛 K 题 CF (排序01背包)
- 山东省第八届ACM省赛K题 CF(01背包,技巧得排序)
- qduoj codeforces 山东省第八届acm省赛K题 CF (排序+01背包)
- 开发微信小程序(3)-全局配置app.json及底部导航栏实现
- Sublime Text3快捷键
- 开机自启动项设置
- echarts实用篇(一)——饼状图
- 哈夫曼树(最优二叉树)
- 山东生第八届acm省赛 cf
- 数据库方法整合
- hdu1061 rightmost digit(C语言)
- Android BroadcastReceiver的注册
- 位、字节、字、kb的关系
- svg transform matrix
- 【转】升级nodejs版本
- 网络连接检测
- Java基础学习总结——Java对象的序列化和反序列化