链接: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. sql server 日期函数

    一.sql server日期时间函数Sql Server中的日期与时间函数 1.  当前系统日期.时间     select getdate()  2. dateadd  在向指定日期加上一段时间的基 ...

  2. K8S从入门到放弃系列-(3)部署etcd集群

    摘要:etcd 是k8s集群最重要的组件,用来存储k8s的所有服务信息, etcd 挂了,集群就挂了,我们这里把etcd部署在master三台节点上做高可用,etcd集群采用raft算法选举Leade ...

  3. Java面试笔记整理4

    一.Java内存溢出的产生原因和解决办法? java.lang.OutOfMemoryError这个错误我相信大部分开发人员都有遇到过,产生该错误的原因大都出于以下原因:JVM内存过小.程序不严密,产 ...

  4. API参考

    http://www.yfvb.com/help/win32sdk/index.htm?page=html/13dsy.g.htm

  5. 【C#】课堂知识点#2

    课堂上老师讲了几点,自己觉得挺重要的,记录下来 1.代码字体调大,方便调试 2.虚心请教,没有谁比谁厉害,不会就虚心多请教,baidu并不能解决所有问题.沟通交流也是一种能力 3.只有每行写对了,才继 ...

  6. CI/CD/Jenkins

    Continuous Integration, Continuous Delivery & Deployment (CI/CD) 持续集成.持续部署&持续交付. Jenkins就是一个 ...

  7. PHP对程序员的要求更高

     我这个文章标题可不是和大家开玩笑的哦  首先, 大家都知道, PHP也是一种编译型脚本语言, 和其他的预编译型语言不同, 它不是编译成中间代码, 然后发布.. 而是每次运行都需要编译.. 为此, 也 ...

  8. (三)Spring框架之事务管理

    一.编程式事务管理 Spring事务管理器的接口是org.springframework.transaction.PlatformTransactionManager,事务管理器接口PlatformT ...

  9. Java BinarySearch

    Java BinarySearch /** * <html> * <body> * <P> Copyright 1994-2018 JasonInternation ...

  10. 十、es6之扩展运算符 三个点(...)

    对象的扩展运算符 对象中的扩展运算符(...)用于取出参数对象中的所有可遍历属性,拷贝到当前对象之中 let bar = { a: 1, b: 2 }; let baz = { ...bar }; / ...