需要按照B/C的值从大到小排序。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
const int INF = 1e9+;
const int maxn = ;
const int MOD = ; int A[maxn], B[maxn], C[maxn];
int dp[];
int vis[maxn]; struct node
{
int A, B, C;
bool friend operator < (node a, node b)
{
return 1.0*a.B/a.C > 1.0*b.B/b.C;
}
}P[maxn]; int main()
{
int T;
scanf("%d", &T); while(T--)
{
int n, t;
scanf("%d %d", &n, &t);
for(int i=; i<=n; i++)
scanf("%d %d %d", &P[i].A, &P[i].B, &P[i].C); sort(P+, P+n+);
memset(dp, , sizeof(dp)); for(int i=; i<= n; i++)
vis[i] = INF; for(int i=; i<=n; i++)
{
for(int j=t; j>=P[i].C; j--)
dp[j] = max(dp[j], dp[j-P[i].C] + P[i].A - P[i].B*j);
} int ans = ;
for(int i=; i<= t; i++)
ans = max(ans, dp[i]); printf("%d\n", ans);
}
return ;
}
/*
1
2 10
110 5 9
30 2 1
*/

HDU 5501 背包问题的更多相关文章

  1. HDU 5501 The Highest Mark 背包dp

    The Highest Mark Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...

  2. HDU 5501 The Highest Mark

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5501 The Highest Mark  Accepts: 32  Submissions: 193 ...

  3. hdu 2126背包问题

    /*有n件物品,旅客一共有m块大洋.第一个问题,旅客最多可以买多少件物品?请注意,这里是多少件,不是价值最大.所以这个非常好求,将所有的物品按照价值排序,先买便宜的,再买贵的.贪心的思想.这个地方有些 ...

  4. HDU 1203 背包问题

    题目大意: 根据学校的申请费用,根据已有的钱得到最大的offer率 这里很明显就是一个价值为概率的背包问题 计算两个offer合并的概率 为a + b - a*b #include <cstdi ...

  5. HDU 5501:The Highest Mark 01背包

    The Highest Mark  Accepts: 71  Submissions: 197  Time Limit: 2000/1000 MS (Java/Others)  Memory Limi ...

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

    题意:类似cf的赛制,每道题目有A,B,C三个值,A表示初始分数,B表示每分钟题的分数会减少B,C表示做这道题需要C分钟,数据保证分数不会变为负数.现在给出比赛时长,问安排做题的顺序,求最大得分. 思 ...

  7. ACboy needs your help hdu 分组背包问题

    Description ACboy has N courses this term, and he plans to spend at most M days on study.Of course,t ...

  8. bone collector hdu 01背包问题

    Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec ...

  9. HDU 5501——The Highest Mark——————【贪心+dp】

    The Highest Mark Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Other ...

随机推荐

  1. shell脚本实现冒泡排序 分类: 学习笔记 linux ubuntu 2015-07-10 14:16 79人阅读 评论(0) 收藏

    手动输入一行字符串,并对其排序. 脚本如下: #!/bin/bash #a test about sort echo "please input a number list" re ...

  2. 15、SQL Server 触发器

    SQL Server 触发器 触发器是一种特殊的存储过程,只有当试图用数据操作语言DML来修改数据时才会触发,DML包含对视图和表的增.删.改. 触发器分为DML触发器和DDL触发器,其中DML触发器 ...

  3. IEqualityComparer 去重

    1.去除list里某重复字段值的数据(相当于group by) public class CorrController { //方法 public void DoGet() { List<tes ...

  4. C# 如何创建接口以及使用接口的简单Demo(转载!)

    //No:1  首先,我们要封装一个接口,接口中不要实现具体的方法(说白了这就是一个架子而已!) using System;using System.Collections.Generic;using ...

  5. jquery生成UUID的方法

    来源:  http://www.broofa.com/2008/09/javascript-uuid-function/ 1.代码:  http://www.broofa.com/Tools/Math ...

  6. oracle 里面定时执行任务,比如存储过程内容等。

    DECLARE   job_no_ NUMBER;   BEGIN      DBMS_JOB.SUBMIT(job_no_,                   'proc_qszx_dw_sc(' ...

  7. 多列的行列转换(PIVOT,UNPIVOT)

    形式1 形式2 形式3 有时候可能会有这样的需求: 将一张表的所有列名转做为数据的一列数据,将一列数据作为整张表的列名 当列比较多时,只用PIVOT是解决不了的,经过研究,需要将UNPIVOT 和 P ...

  8. UITableViewCell 添加长按手势

    UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self actio ...

  9. c++文件读写相关

    在看C++编程思想中,每个练习基本都是使用ofstream,ifstream,fstream,以前粗略知道其用法和含义,在看了几位大牛的博文后,进行整理和总结: 这里主要是讨论fstream的内容: ...

  10. 【POJ3580】【splay版】SuperMemo

    Description Your friend, Jackson is invited to a TV show called SuperMemo in which the participant i ...