栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 3689 Digging

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 3689 Digging

#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define N 3005struct node{ int t,s;}pnt[N];bool cmp(const node &a,const node &b){ int v1=(a.t+b.t)*a.s+b.t*b.s; int v2=(a.t+b.t)*b.s+a.t*a.s; return v1<v2;}int dp[10005];int main(){ int n,T; while(cin>>n>>T){ for(int i=0;i<n;i++) scanf("%d%d",&pnt[i].t,&pnt[i].s); sort(pnt,pnt+n,cmp); memset(dp,0,sizeof(dp)); for(int i=0;i<n;i++){ for(int j=T;j>0;j--){ if(pnt[i].t>j) break; dp[j]=max(dp[j],dp[j-pnt[i].t]+j*pnt[i].s); } } printf("%dn",dp[T]); } return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/378119.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号