[2016-02-04][HDU][5501][The Highest Mark]

[2016-02-04][HDU][5501][The Highest Mark]

HDU - 5501

The Highest Mark

Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %I64d & %I64u

Submit Status

Description

The SDOI in $2045$ is far from what it was been $30$ years ago. Each competition has $t$ minutes and $n$ problems.

The $ith$ problem with the original mark of $A_i(A_i \leq 10^{6})$,and it decreases $B_i$ by each minute. It is guaranteed that it does not go to minus when the competition ends. For example someone solves the $ith$ problem after $x$ minutes of the competition beginning. He/She will get $A_i-B_i * x$ marks.

If someone solves a problem on $x$ minute. He/She will begin to solve the next problem on $x+1$ minute.

dxy who attend this competition with excellent strength, can measure the time of solving each problem exactly.He will spend $C_i(C_i \leq t)$ minutes to solve the ith problem. It is because he is so godlike that he can solve every problem of this competition. But to the limitation of time, it‘s probable he cannot solve every problem in this competition. He wanted to arrange the order of solving problems to get the highest mark in this competition.

Input

There is an positive integer $T(T \leq 10)$ in the first line for the number of testcases.(the number of testcases with $n>200$ is no more than $5$)

For each testcase, there are two integers in the first line $n(1 \leq n \leq 1000)$ and $t(1 \leq t \leq 3000)$ for the number of problems and the time limitation of this competition.

There are $n$ lines followed and three positive integers each line $A_i, B_i, C_i$. For the original mark,the mark decreasing per minute and the time dxy of solving this problem will spend.

Hint:
First to solve problem $2$ and then solve problem $1$ he will get $88$ marks. Higher than any other order.

Output

For each testcase output a line for an integer, for the highest mark dxy will get in this competition.

Sample Input

1
4 10
110 5 9
30 2 1
80 4 8
50 3 2 

Sample Output

88 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

#include<cstdio>

#include<algorithm>

#include<vector>

#include<cstring>

#include<map>

using namespace std;

const int maxn = 1000 + 10;

struct Problem{

    int A,B,C;

}ps[maxn];

int solved[maxn];

int main(){

    int T;

    scanf("%d",&T);

    while(T--)

    {

        int n,t;

        scanf("%d%d",&n,&t);

        for(int i= 0; i < n;i++)

            scanf("%d%d%d",&ps[i].A,&ps[i].B,&ps[i].C);

        memset(solved,0,sizeof(solved));

        int cur = 0;

        int res = 0;

        while(cur < t)

        {

            int maxid = -1,maxscore = -1;

            for(int i = 0; i < n;i++)

            {

                if(!solved[i] && cur + ps[i].C <= t){

                    int score = ps[i].A - ps[i].B*(cur + ps[i].C);

                    if(score > maxscore)

                    {

                        maxid = i;

                        maxscore = score;

                    }

                }

            }

            if(maxid == -1)   break;

            solved[maxid] = 1;

            res += maxscore;

            cur += ps[maxid].C;

        }

        printf("%d\n",res);

    }

    return 0;

}

来自为知笔记(Wiz)

时间: 2024-09-12 16:10:15

[2016-02-04][HDU][5501][The Highest Mark]的相关文章

HDU 5501 The Highest Mark (贪心+DP,经典)

题意: 有n道题目,每道题目的初始分数为Ai,分数每分钟减少Bi,完成此题需要Ci分钟,问在t分钟内最多能获得多少分? 思路: 好题~ 如果没有B的话,就是一道裸的01背包的题目了.每道题目的得分为:v=A-B*g  (其中g为完成这道题目的时刻),想要用背包解的话是可以的,但是完成的次序不同的话,得分也可能受到影响.那就排个序得了,问题在于如何排序?假设已经确定要做哪些题了,则如果交换了相邻两道题的位置,对总分数是有益的,那么肯定是换了,而且他们对其他的题目完全无影响,不妨假设只有两道题要完成

hdu 5501 The Highest Mark(贪心+01背包)

题意:类似cf的赛制,每道题目有A,B,C三个值,A表示初始分数,B表示每分钟题的分数会减少B,C表示做这道题需要C分钟,数据保证分数不会变为负数.现在给出比赛时长,问安排做题的顺序,求最大得分. 思路:这道题是一道非常经典的题.首先很容易想到一件事,给出的题哪个先做没有先后顺序,那么在动态规划的时候,必然有前后顺序,所以要么就是状态压缩,要么就是之前就把这些题目排序了,使得后面是有序的.状压不用考虑了因为数据太大,所以我们考虑要如何排序. 现在有A1,B1,C1和A2,B2,C2这两道题,如果

2016/02/21 codes

var Class = { create:function(){ var parent = null,properties = $A(arguments); if(Object.isFunction(properties[0])) parent = properties.shift(); function kclass(){ this.initialize.apply(this.arguments); } Object.extend(kclass,Class.Methods); kclass.s

FFMpeg ver 20160219-git-98a0053 滤镜中英文对照 2016.02.21 by 1CM

FFMpeg ver 20160219-git-98a0053 滤镜中英文对照 2016.02.21 by 1CM T.. = Timeline support 支持时间轴 .S. = Slice threading 分段线程 ..C = Command support 支持命令传送 A = Audio input/output 音频 输入/输出 V = Video input/output 视频 输入/输出 N = Dynamic number and/or type of input/out

Oracle数据库创建与安装_超越OCP精通Oracle视频教程培训02~04

_超越OCP精通Oracle视频教程培训02~04 学完本Oracle视频教程能掌握以下内容: Oracle数据库相关概念/体系结构/物理结构/逻辑结构 Oracle数据库GRID组件与ASM存储概念 VMware虚拟机的安装与主机环境的配置 Windows2008 Server操作系统安装 Linux操作系统安装与基本配置 Windows/Linux操作系统Oracle 11g数据库软件的安装 Windows/Linux操作系统Oracle 11g数据库的创建 Linux上Oracle11g基

2016年04月MVP开始申请了~[截止时间:1月12日]

51CTO与微软中国合作长期为用户提供申请"微软最有价值专家"的平台希望有兴趣.资历的朋友以及正在朝这个方向努力的朋友能够积极参与只要您想参与我们将为您向微软推荐 微软最有价值专家MVP一年评选4次分别为每年的1月.4月.7月.10月.2016年4月的MVP申请截止时间是2016年1月12日. 申请MVP的午饭请下载2016年4月MVP申请表填好后发送到[email protected].我们会在每次MVP申请开始时把用户提交的申请表格推荐到微软中国相关部门 [注意事项]1.51CTO

2016/02/20 codes

<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <title>2016/02/20</title></head><body><div id="mainDiv"> <div id = "content"> <div id = &qu

分布式技术一周技术动态 2016.02.21

分布式系统实践 1. 远程接口设计经验分享 http://mp.weixin.qq.com/s?__biz=MzAwNjQwNzU2NQ%3D%3D&idx=2&mid=402064901&scene=0&sn=0b5f56a97b431ed355b75a9e17f2e754 要点: 分布式系统由于中间存在网络因素, 出错的情况比单机系统要多很多, 那么如何设计一个远程接口呢? 本文很好的解释了设计远程接口需要考虑的问题点. 2. 时序列数据库武斗大会之什么是TSDB ht

The Highest Mark(01背包)

The Highest Mark Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 247    Accepted Submission(s): 101 Problem Description The SDOI in 2045 is far from what it was been 30 years ago. Each competi