链接: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. [转帖]PostgreSQL 昨天,今天和明天

    PostgreSQL 昨天,今天和明天 http://www.postgres.cn/v2/news/viewone/1/52 原作者:何伟平(laser) 创作时间:2005-01-15 11:44 ...

  2. java基础--Java虚拟机

    ·JVM (Java Virtual Machine ):Java虚拟机,简称JVM,是运行所有Java程序的假想计算机,是Java程序的运行环境,是Java 最具吸引力的特性之一.我们编写的Java ...

  3. 版本管理——Git和SVN的介绍及其优缺点

    版本管理 概念:版本管理是软件配置管理的基础,它管理并保护开发者的软件资源.   好处:可以保留我们的历史版本,在代码开发到一半的时候,不至于无故丢失,还可以查看BUG的来龙去脉.   版本管理种类: ...

  4. 排查java 内存CPU报警

    #!/bin/bash source /etc/profile #接收外部传入PID,任选一种 #servicePid=$1 headPid=`ps auxw|sort -rn -k3|head -4 ...

  5. js — 对象

    目录 1. 字符串和数值之间转换 2. 对象(object) 3. 日期对象 4. 数学Math对象 5. 流程控制 6. 循环 1. 字符串和数值之间转换 1.字符串转数值 var str = '1 ...

  6. Java+Tomcat 环境部署

    Java+Tomcat 环境部署 下面在Centos7进行安装Java+Tomcat,网上的很多文章,我在部署中都有些问题,下面是我自己总结的一个安装过程! 安装Java环境 首先,我们先到Java官 ...

  7. Django中常用的那些模块路径

    Django中常用的那些模块路径 from django.shortcuts import HttpResponse, render, redirect from django import temp ...

  8. docker&k8s-配置/常用命令

      kubectl delete deployment,ingress,svc demo-mml-jp-ylmopt-web-1 -n demo-mml  #删除预生产环境mml组ylmopt-web ...

  9. go for range 可以方便的对slice 切片或者 map 进行迭代循环

    package main import (     "fmt"     "math/rand"     "time" ) func main ...

  10. preg_replace

    preg_replace — 执行一个正则表达式的搜索和替换 说明: preg_replace ( mixed $pattern , mixed $replacement , mixed $subje ...