uva 12563 - Jin Ge Jin Qu hao
来源:互联网 发布:钢琴知乎 编辑:程序博客网 时间:2024/05/22 06:28
/************************************************************************* > File Name: vj.cpp > Author: bxf > Mail: bbb546754186@vip.qq.com > Created Time: 2014年08月04日 星期一 19时35分22秒 ************************************************************************/#include <iostream>#include <cstring>#include <cstdlib>#include <set>#include <cstdio>#include <string>#include <vector>#include <map>#include <cmath>#include <algorithm>#define INF 0xfffffff#define maxn 50 + 10#define ll long longusing namespace std;int a[maxn], dp[maxn][10000];int main(){int t, kase = 0;scanf("%d", &t);while(t--){int n, tottime;scanf("%d%d", &n, &tottime);for(int i = 1; i <= n; ++i)scanf("%d", &a[i]);sort(a+1, a+n+1);memset(dp, 0, sizeof(dp));dp[0][0] = 1;for(int i = 1; i <= n; ++i)for(int j = tottime-1; j >= a[i]; --j)for(int k = i; k >= 1; --k)if(dp[k-1][j-a[i]])dp[k][j] = 1;int ans = 0, num = 0;bool ok = false;for(int i = n; i>= 1; --i){for(int j = tottime-1; j >= 0; --j)if(dp[i][j]){ans = j;num = i;ok = true;break;}if(ok) break;}printf("Case %d: %d %d\n", ++kase, num+1, ans+678);} return 0;}
0 0
- uva 12563 - Jin Ge Jin Qu hao
- UVa 12563 Jin Ge Jin Qu hao
- UVa - 12563 - Jin Ge Jin Qu hao
- UVA - 12563 Jin Ge Jin Qu hao
- UVA 12563:jin ge jin qu hao
- uva 12563Jin Ge Jin Qu hao
- uva 12563 Jin Ge Jin Qu hao
- UVA 12563 Jin Ge Jin Qu hao
- UVA 12563 Jin Ge Jin Qu hao
- UVA 12563 Jin Ge Jin Qu hao
- UVa 12563_Jin Ge Jin Qu hao
- Jin Ge Jin Qu hao UVA
- Jin Ge Jin Qu hao UVA
- Jin Ge Jin Qu hao UVA
- Jin Ge Jin Qu hao UVA
- Jin Ge Jin Qu hao - UVa 12563 dp背包
- UVA 12563 Jin Ge Jin Qu hao(DP)
- UVA - 12563 Jin Ge Jin Qu hao (01背包)
- 算法竞赛入门经典-第五章源代码
- C++设计模式之单例模式
- POJ 3318 Matrix Multiplication(随机化算法)
- 知识点:各种容器介绍(示例为TreeSet),TreeSet的遍历
- Exponentiation(高精度)
- uva 12563 - Jin Ge Jin Qu hao
- mysql的数据类型
- PHP的POST处理方法汇总
- xen.cfg的写法及附带的一个例子
- poj 3692 Kindergarten 二分匹配
- Codeforces 417D
- hdu 1004 Let the Balloon Rise
- 银行业务调度的理解
- jQuery 学习(四)