 # The Highest Mark

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 630    Accepted Submission(s): 260

Problem Description
The SDOI in

Input
There is an positive integer

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

Source #include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
typedef long long INT;
const int maxn = 1e5+200;
struct Problem{
INT a,b,c;
}pros[maxn];
INT dp[maxn];
bool cmp(Problem aa,Problem bb){
return (aa.b*1.0 / aa.c) > (bb.b*1.0 / bb.c);   // >
}
int main(){
int n,t,T;
while(T--){
scanf("%d%d",&n,&t);
memset(dp,0,sizeof(dp));
for(int i = 1; i <= n; i++){
scanf("%lld%lld%lld",&pros[i].a,&pros[i].b,&pros[i].c);
}
sort(pros+1, pros+1+n, cmp);
for(int i = 1; i <= n; i++){
for(int j = t; j >=pros[i].c ; j--){
dp[j] = max(dp[j], dp[j-pros[i].c] + pros[i].a - (j * pros[i].b) );
}
}
INT ans = dp;
for(int i = 1; i <= t; i++){
ans = max(ans, dp[i]);
}
printf("%lld\n",ans);
}
return 0;
}


posted @ 2015-10-19 12:48  tcgoshawk  阅读(190)  评论(0编辑  收藏  举报