#include <cstdio>
#include <iostream>
using namespace std;
const int M = 10000;
struct node{
int x, y;
node(int _x = 0, int _y = 0):x(_x), y(_y){}
};
int v[M];
node dp[M];
int main()
{
int s, t, cas = 1, n;
cin >> t;
while(t--){
cin >> n >> s;
for(int i = 0; i < M; i++) dp[i].x = dp[i].y = 0;
for(int i = 0; i < n; i++) scanf("%d",&v[i]);
s--;
for(int i = 0; i < n; i++){
for(int j = s; j >= v[i]; j--){
int a1 = dp[j-v[i]].x + 1;
if(a1 > dp[j].x){
dp[j].x = a1;
dp[j].y = dp[j-v[i]].y + v[i];
}
else if(a1 == dp[j].x){
dp[j].y = max(dp[j].y, dp[j-v[i]].y + v[i]);
}
}
}
int x = dp[s].x+1, y = dp[s].y + 678;
printf("Case %d: %d %d\n", cas++, x, y);
}
return 0;
}
/*
总时间不会超过1万
记录两个状态,先保证数目最多,再保证时间最长
*/
07-10
07-10
07-10
07-10
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交