#include <iostream>
#include <cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int dp[][];
struct point{
int t,s;
}ps[];
bool cmp(point A, point B)
{
return A.t*B.s < B.t*A.s;//比较大小的时候千万不要 计算出数值进行比较
}
int main(){
int n,t;
int i,j;
while(cin>>n>>t){
for(i=;i<n;i++)
{
cin>>ps[i].t>>ps[i].s;
}
sort(ps,ps+n,cmp);
memset(dp,,sizeof(dp));
int ma=-;
for(i=;i<=n;i++){
for(j=ps[i-].t;j<=t;j++){
dp[i%][j]=max(dp[(i-)%][j],dp[(i-)%][j-ps[i-].t]+ps[i-].s*(t-(j-ps[i-].t)));
if(i==n) ma=max(ma,dp[i%][j]);
}
}
/* for(int i = 0; i < n; i++)
for(int j = t; j >= ps[i].t; j--){
int index=0;
dp[index][j] = max(dp[index][j], dp[index][j-ps[i].t]+(t-j+ps[i].t)*ps[i].s);
if(i==n-1) ma=max(ma,dp[index][j]);
}*/
cout<<ma<<endl;
}
return ;
}

ZOJ3689 Digging(01背包)的更多相关文章

  1. D - Digging(01背包,贪心)

    D - Digging Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit St ...

  2. bnu 28890 &zoj 3689——Digging——————【要求物品次序的01背包】

    Digging Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 36 ...

  3. UVALive 4870 Roller Coaster --01背包

    题意:过山车有n个区域,一个人有两个值F,D,在每个区域有两种选择: 1.睁眼: F += f[i], D += d[i] 2.闭眼: F = F ,     D -= K 问在D小于等于一定限度的时 ...

  4. POJ1112 Team Them Up![二分图染色 补图 01背包]

    Team Them Up! Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7608   Accepted: 2041   S ...

  5. Codeforces 2016 ACM Amman Collegiate Programming Contest A. Coins(动态规划/01背包变形)

    传送门 Description Hasan and Bahosain want to buy a new video game, they want to share the expenses. Ha ...

  6. 51nod1085(01背包)

    题目链接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1085 题意: 中文题诶~ 思路: 01背包模板题. 用dp[ ...

  7. *HDU3339 最短路+01背包

    In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  8. codeforces 742D Arpa's weak amphitheater and Mehrdad's valuable Hoses ——(01背包变形)

    题意:给你若干个集合,每个集合内的物品要么选任意一个,要么所有都选,求最后在背包能容纳的范围下最大的价值. 分析:对于每个并查集,从上到下滚动维护即可,其实就是一个01背包= =. 代码如下: #in ...

  9. POJ 3624 Charm Bracelet(01背包)

    Charm Bracelet Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 34532   Accepted: 15301 ...

随机推荐

  1. IBM X System ServerGuide 8.41 服务器 系统安装 引导盘

    IBM X System ServerGuide 8.41 支持操作系统: 32位: Microsoft Windows 2003/2003 R2 (Enterprise, Standard, Web ...

  2. Oracle EBS-SQL (SYS-12):查询各Profile的设置情况.sql

    SELECT pro.profile_option_name, pro.user_profile_option_name, lev.level_type TYPE, --lev.level_code, ...

  3. hdu4288 Coder

    Coder Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  4. poj2231---暴力

    #include<stdio.h> #include<stdlib.h> #include<math.h> ]; int cmp(const void *a,con ...

  5. openNebula libvirt-virsh attach disk device for kvm

    1,新建文件硬盘 qemu-img create -f qcow2 testdisk.img 2G

  6. 轻奢当道业绩逆势增长 Kate Spade联手韩国衣恋开拓中国市场_商场报道_中国时尚品牌网

    轻奢当道业绩逆势增长 Kate Spade联手韩国衣恋开拓中国市场_商场报道_中国时尚品牌网 轻奢当道业绩逆势增长 Kate Spade联手韩国衣恋开拓中国市场

  7. Qt编写端口扫描工具

    Qt提供了QTcpSocket类,可以方便地建立TCP连接.利用这一功能,Maxiee编写了一个简单地端口扫描工具. 软件的功能就是,扫描某一网段的固定端口,如80端口,若目的地址开放了这一端口,那么 ...

  8. python socket理论知识

    一.socket理论: 发现一个很好的文章,一个高手写的,我也就不再做搬运工了,直接连接吧,对理论感兴趣的可以去看看! http://www.cnblogs.com/dolphinX/p/346054 ...

  9. NYOJ-252 01串

    01串 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描写叙述 ACM的zyc在研究01串,他知道某一01串的长度,但他想知道不含有"11"子串的这样的长 ...

  10. framework层和native层实现联网控制(iptable方式)

    最近工作中,需要开发一个功能----联网控制,这个功能其实用过root的安卓机应该都知道,禁止某个应用连接移动网络或者wifi. root后,通过su去执行iptable的命令就可以根据uid去控制应 ...