码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-02-05 01:54:21      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:

[2016-02-04][HDU][5501][The Highest Mark]
HDU - 5501
Time Limit: 1000MSMemory Limit: 131072KB64bit IO Format: %I64d & %I64u

 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;
}





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

标签:

原文地址:http://www.cnblogs.com/qhy285571052/p/5182494.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!