链接:https://ac.nowcoder.com/acm/problem/21314
来源:牛客网

题目描述

牛牛正在打一场CF
比赛时间为T分钟,有N道题,可以在比赛时间内的任意时间提交代码
第i道题的分数为maxPoints[i],题目的分数随着比赛的进行,每分钟减少pointsPerMinute[i]
这是一场比较dark的Cf,分数可能减成负数
已知第i道题需要花费 requiredTime[i] 的时间解决
请问最多可以得到多少分

输入描述:

第一行输入两个整数N,T (1 ≤ N ≤ 50, 1 ≤ T ≤ 100000)
第二行输入n个整数maxPoints[i]
第三行输入n个整数pointsPerMinute[i]
第四行输入n个整数requiredTime[i]
1 ≤ maxPoints[i],pointsPerMinute[i],requiredTime[i] ≤ 100000

输出描述:

输出一个整数
示例1

输入

1 74
502
2
47

输出

408
示例2

输入

2 40000
100000 100000
1 100000
50000 30000

输出

0
示例3

输入

3 75
250 500 1000
2 4 8
25 25 25

输出

1200
示例4

输入

3 30
100 100 100000
1 1 100
15 15 30

输出

97000

备注:

子任务1: n <= 10
子任务2: n <= 20
子任务3: 无限制
题意:给出一些任务,每个任务都有一个初始分ai,每分钟会降低bi(可以降低到负分),完成这个任务需要花费ci分钟,求最多可以得到的分数
题解:容易看出是个dp,又由于bi影响着ai每个时刻的值,所以做任务的顺序影响着dp结果,想要得到最优的dp结果就需要进行排序,假设有两个任务1和2,那么二者可以得到的分数为如果先做1,则=a1+a2-b1*c1-b2*(c1+c2),如果先做2,则=a1+a2-b2*c2-b1*(c1+c2),则排序条件就应该是a1+a2-b1*c1-b2*(c1+c2)>a1+a2-b2*c2-b1*(c1+c2)
 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct pot{
ll q;
ll w;
ll e;
}p[];
bool cmp(struct pot aa,struct pot bb){
return (aa.e+bb.e)*bb.w+aa.e*aa.w<(aa.e+bb.e)*aa.w+bb.e*bb.w;
}
ll dp[];
int main()
{
ll n,t;
scanf("%lld%lld",&n,&t);
for(int i=;i<=n;i++){
scanf("%lld",&p[i].q);
}
for(int i=;i<=n;i++){
scanf("%lld",&p[i].w);
}
for(int i=;i<=n;i++){
scanf("%lld",&p[i].e);
}
ll ans=;
sort(p+,p++n,cmp);
for(int i=;i<=n;i++){
for(int j=t;j>=p[i].e;j--){
dp[j]=max(dp[j],dp[j-p[i].e]+p[i].q-(p[i].w)*(j));
ans=max(ans,dp[j]);
}
}
printf("%lld\n",ans);
return ;
}

[codeforces][dp]的更多相关文章

  1. Codeforces Round 536 (Div. 2) (E)

    layout: post title: Codeforces Round 536 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  2. (寒假开黑gym)2018 ACM-ICPC, Syrian Collegiate Programming Contest(爽题)

    layout: post title: (寒假开黑gym)2018 ACM-ICPC, Syrian Collegiate Programming Contest(爽题) author: " ...

  3. SOSdp

    layout: post title: SOSdp author: "luowentaoaa" catalog: true tags: mathjax: true - codefo ...

  4. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  5. codeforces 721C (拓排 + DP)

    题目链接:http://codeforces.com/contest/721/problem/C 题意:从1走到n,问在时间T内最多经过多少个点,按路径顺序输出. 思路:比赛的时候只想到拓排然后就不知 ...

  6. Codeforces Round #369 (Div. 2)---C - Coloring Trees (很妙的DP题)

    题目链接 http://codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has a ...

  7. codeforces Hill Number 数位dp

    http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits:  5000 MS   Memory Limits: ...

  8. codeforces Diagrams & Tableaux1 (状压DP)

    http://codeforces.com/gym/100405 D题 题在pdf里 codeforces.com/gym/100405/attachments/download/2331/20132 ...

  9. codeforces 425C Sereja and Two Sequences(DP)

    题意读了好久才读懂....不知道怎么翻译好~~请自便~~~ http://codeforces.com/problemset/problem/425/C 看懂之后纠结好久...不会做...仍然是看题解 ...

随机推荐

  1. [转帖]微软宣布即将开始大规模推送Windows 10 V1903重大版本更新

    微软宣布即将开始大规模推送Windows 10 V1903重大版本更新 https://www.cnbeta.com/articles/tech/894303.htm 微软要批量更新 1903了 bu ...

  2. insert 一条数据 然后拿出这条数据在数据库中生成的ID

    [insert 一条数据 然后拿出这条数据在数据库中生成的ID] <insert id="insert" parameterType="management&quo ...

  3. phpstrom

    在phpstrom 中启用composer 步骤: 1.打开编辑器,选择 文件(file)->设置(setting),找到 Command Line Tool Support ,点击 + 号进行 ...

  4. 使用Duilib开发Windows软件(4)——消息传递

    云信Duilib中没有窗体类的函数可以用来直接收取到所有控件的事件,每个控件都可以单独设置自己的事件处理函数,一般在InitWindow方法中初始化各个控件的事件处理函数. 每个控件都有许多形如Att ...

  5. 【满k叉树】Perfect Tree

    题目描述 Given a positive integer k, we define a rooted tree to be k-perfect, if and only if it meets bo ...

  6. 【搜索+set去重】Balance Scale

    Balance Scale 题目描述 You, an experimental chemist, have a balance scale and a kit of weights for measu ...

  7. Solr综合案例深入练习

    1. 综合案例 1.1. 需求 使用Solr实现电商网站中商品信息搜索功能,可以根据关键字.分类.价格搜索商品信息,也可以根据价格进行排序,并且实现分页功能. 界面如下: 1.2. 分析 开发人员需要 ...

  8. 使用DANT做FTP的转发代理

    FTP不能直接使用nginx进行转发,想了一些办法,最后决定使用iptalbes做DNAT,相关于把这个机器做一台防火墙,做一个NAT 1.启用ip_forward vim /etc/sysctl.c ...

  9. 2019杭电多校一 C. Milk (dp)

    大意: $n*m$棋盘, 初始位置$(1,1)$, 横坐标为$\frac{m+1}{2}$时可以向下走, 否则只能左右走, 每走一步花费$1$秒. 有$k$管奶, 第$i$罐位置$(r_i,c_i)$ ...

  10. C# Entity Framework The ObjectContext instance has been disposed and can no longer be used for operations that require a connection

    The ObjectContext instance has been disposed and can no longer be used for operations that require a ...