#include<iostream>
#include<algorithm>
#define MAXN 201
#define count C_ount
using namespace std; int _m[][];
int count[][];
int a[]; struct _node
{
int first;
int second;
}; _node _cand[MAXN];
int n;
int main()
{
//freopen("acm.acm","r",stdin);
int m;
int i;
int j;
int time;
int max;
int u;
int v;
int u_v;
int _i;
int _j;
int _test_time = ;
int index;
int ans;
while(cin>>n>>m,n||m)
{
memset(count,-,sizeof(count));
memset(_m,-,sizeof(_m));
max = m*;
for(i = ; i < n; ++ i)
{
cin>>u>>v;
_cand[i].first = u - v;
_cand[i].second = u + v;
}
for(i = ; i < n; ++ i)
{
if(count[][max+_cand[i].first] < _cand[i].second)
{
_m[][max+_cand[i].first] = i;
count[][max+_cand[i].first] = _cand[i].second;
}
}
for(time = ; time < m-; ++ time)
{
for(u_v = ; u_v <= max*; ++ u_v)
{
if(_m[time][u_v] != -)
{
for(i = ; i < n; ++ i)
{
if(count[time+][u_v + _cand[i].first] < count[time][u_v] + _cand[i].second)
{
_j = u_v;
for(_i = time; _i >= ; -- _i)
{
if(_m[_i][_j] == i)
break;
_j -= _cand[_m[_i][_j]].first;
}
if(_i < )
{
_m[time+][u_v+_cand[i].first] = i;
count[time+][u_v+_cand[i].first] = count[time][u_v] + _cand[i].second;
}
}
}
}
}
} ///////////// for(i = ; i <= max; ++ i)
{
int tem_1 = count[m-][max+i];
int tem_2 = count[m-][max-i];
if( (tem_1 = count[m-][max+i]) >= || (tem_2 = count[m-][max-i]) >= )
{
if(tem_1 > tem_2)
{
ans = max+i;
}
else
{
ans = max-i;
}
break;
}
}
cout<<"Jury #"<<++ _test_time<<endl;
cout<<"Best jury has value "<<(count[m-][ans] + (ans - max))/<<" for prosecution and value "<<(count[m-][ans] - (ans - max))/<<" for defence:"<<endl;
j = ans;
index = ;
for(i = m-; i >= ; -- i)
{
a[index ++] = _m[i][j];
j -= _cand[_m[i][j]].first;
}
sort(a,a+index);
for(i = ; i < index; ++ i)
{
cout<<" "<<a[i]+;
}
cout<<endl;
cout<<endl;
}
}

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com

POJ 1015的更多相关文章

  1. OpenJudge 2979 陪审团的人选 / Poj 1015 Jury Compromise

    1.链接地址: http://bailian.openjudge.cn/practice/2979 http://poj.org/problem?id=1015 2.题目: 总Time Limit: ...

  2. 背包系列练习及总结(hud 2602 && hdu 2844 Coins && hdu 2159 && poj 1170 Shopping Offers && hdu 3092 Least common multiple && poj 1015 Jury Compromise)

    作为一个oier,以及大学acm党背包是必不可少的一部分.好久没做背包类动规了.久违地练习下-.- dd__engi的背包九讲:http://love-oriented.com/pack/ 鸣谢htt ...

  3. POJ 1015 Jury Compromise 2个月后重做,其实这是背包题目

    http://poj.org/problem?id=1015 题目大意:在遥远的国家佛罗布尼亚,嫌犯是否有罪,须由陪审团决定.陪审团是由法官从公众中挑选的.先随机挑选n个人作为陪审团的候选人,然后再从 ...

  4. (最优m个候选人 和他们的编号)Jury Compromise (POJ 1015) 难

    http://poj.org/problem?id=1015   Description In Frobnia, a far-away country, the verdicts in court t ...

  5. POJ 1015 Jury Compromise dp分组

    第一次做dp分组的问题,百度的~~ http://poj.org/problem?id=1015 题目大意:在遥远的国家佛罗布尼亚,嫌犯是否有罪,须由陪审团决定.陪审团是由法官从公众中挑选的.先随机挑 ...

  6. [Poj 1015] Jury Compromise 解题报告 (完全背包)

    题目链接:http://poj.org/problem?id=1015 题目: 题解: 我们考虑设计DP状态(因为这很显然是一个完全背包问题不是吗?) dp[j][k]表示在外层循环到i时,选了j个人 ...

  7. POJ #1015 - Jury Compromise - TODO: POJ website issue

    (poj.org issue. Not submitted yet) This is a 2D DP problem, very classic too. Since I'm just learnin ...

  8. Jury Compromise POJ - 1015 dp (标答有误)背包思想

    题意:从 n个人里面找到m个人  每个人有两个值  d   p     满足在abs(sum(d)-sum(p)) 最小的前提下sum(d)+sum(p)最大 思路:dp[i][j]  i个人中  和 ...

  9. HDU POJ 1015 Jury Compromise(陪审团的人选,DP)

    题意: 在遥远的国家佛罗布尼亚,嫌犯是否有罪,须由陪审团决定.陪审团是由法官从公众中挑选的.先随机挑选n个人作为陪审团的候选人,然后再从这n个人中选m人组成陪审团.选m人的办法是:控方和辩方会根据对候 ...

  10. poj 1015 Jury Compromise_dp

    题意:n个陪审团,每个陪审团有x,y值,选出m个陪审团,要求 (sum(xi)-sum(yi))最少,当 (sum(xi)-sum(yi))最少有多个,取sum(xi)+sum(yi)最大那个 ,并顺 ...

随机推荐

  1. 说说wee sing(ZZ)

    我自己在当当上买过wee sing,也在网上下了wee sing 的DVD,也借过同事在淘宝上买的Wee sing 套装(9cd + 5DVD).所以对这套资料还是很熟悉的.      淘宝上的套装卖 ...

  2. 27. Green Building 绿色建筑

    27. Green Building 绿色建筑 ①When we think of green buildings,we tend to think of new ones-the kind of h ...

  3. 【Unity】2.4 层次视图(Hierarchy)

    分类:Unity.C#.VS2015 创建日期:2016-03-29 一.简介 层级视图 (Hierarchy) 包含当前场景中的每个游戏对象 (GameObject).有些是三维模型等资源文件的直接 ...

  4. js 验证input 输入框

    <h1>js验证输入框内容</h1><br /><br /> 只能输入英文<input type="text" onkeyup ...

  5. HDU 2161 Primes (素数筛选法)

    题意:输入一个数判断是不是素数,并规定2不是素数. 析:一看就很简单吧,用素数筛选法,注意的是结束条件是n<0,一开始被坑了... 不说了,直接上代码: #include <iostrea ...

  6. GitBash入门

    转载自:http://www.cnblogs.com/randomsteps/p/5415116.html 作为一个初学者,我是跟着廖学峰老师的官方博客学习,这里只是做个笔记,哈哈,关于git的历史. ...

  7. 全面理解iOS开发中的Scroll View[转]

    from:http://mobile.51cto.com/hot-430409.htm 可能你很难相信,UIScrollView和一个标准的UIView差异并不大,scroll view确实会多一些方 ...

  8. 好久不发帖,转一下公司技术美术独立完成的U3D模拟暗黑泰瑞尔翅膀物理运动效果

    想入公司倍培养成为优秀的技术型美术,欢迎call我! Max制作翅膀模型部分 新建一个片面,模型给一些段数,赋予一张左右二方连续贴图. 加个FFD 4*4*4,并稍微拉出一点弧度. 将头尾的Alpha ...

  9. Thread in depth 2:Asynchronization and Task

    When we want to do a work asynchronously, creating a new thread is a good way. .NET provides two oth ...

  10. java keytool生成ssl加密密钥

    教程:http://www.cnblogs.com/getherBlog/p/3930317.html 其中用到几个命令: keytool -genkeypair -alias certificate ...