链接: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. Django mysql-client

    sudo apt-get install libmysqlclient-dev 报错,mysqlclient 没有安装 :实际已经安装,这是因为mysql安装时没有安装好 https://www.cn ...

  2. 【LOJ】#3020. 「CQOI2017」小 Q 的表格

    #3020. 「CQOI2017」小 Q 的表格 这个的话求出来\(g = gcd(a,b)\) 会修改所有gcd为g的位置 我们要求\((g,g)\)这个位置的数一定是\(g^{2}\)的倍数 之后 ...

  3. java模拟from表单提交,上传图片

    /** * java上传表单,有图片 * @param urlStr 上传地址 * @param textMap 表单参数 * @param fileMap 文件参数 key:文件名称 value:文 ...

  4. linux破解navicat for mysql

    第一次执行start_navicat时,会在用户主目录下生成一个名为.navicat64的隐藏文件夹. cd ~/.navicat64 此文件夹下有一个system.reg文件 rm system.r ...

  5. 【判环】Perpetuum Mobile

    Perpetuum Mobile 题目描述 The year is 1902. Albert Einstein is working in the patent office in Bern. Many ...

  6. k8s系列0--Kubernetes基础知识

    Kubernetes介绍 参考:Kubernetes核心组件解析 Pod是k8s的最小调度单元 每个pod有独立的IP,但是pod的IP是不可靠的,重新调度pod就会改变IP,service概念就是为 ...

  7. (十二)SpringBoot之Spring-Data-Jpa(一)

    一.Spring-Data-Jpa概念 JPA(Java Persistence API)定义了一系列对象持久化的标准,目前实现这一规范的产品有Hibernate.TopLink等. Spring D ...

  8. django 2.0 xadmin 错误集锦

    转载 django 2.0 xadmin 错误集锦 2018-03-26 10:39:18 Snail0Li 阅读数 5188更多 分类专栏: python   1.django2.0把from dj ...

  9. Java 面向对象(三)static 关键字

    一.static 1.概述 static 的意思的静态的,也是一种修饰符. 关于 static 关键字的使用,它可以用来修饰的成员变量和成员方法,被修饰的成员是属于类的,而不是单单属于某个对象的. 用 ...

  10. KVM之virsh管理Storage pool

    创建基于文件夹的存储池 基于文件夹的存储池: [root@ubuntu01 ~]# mkdir /data/vm_pool [root@ubuntu01 ~]# virsh pool-create-a ...