Uva 12563
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define MAX (180*50+678+100)
using namespace std;
int nums[MAX+1];
int main()
{
freopen("sb.txt","r",stdin);
int count;
cin >> count;
int gjj = 678;
for (int i = 0; i < count; i++)
{
fill(nums, nums + MAX, -0x3f3f3f3f);
int size, T;
cin >> size >> T;
int sum = 0;
for (int j = 0; j < size; j++)
{
int w;
cin >> w;
nums[0] = 0;
for (int k = T; k >= 0; k--)
{
if (k >= w)
{
nums[k] = max(nums[k], nums[k - w] + 1);
}
}
}
int ans=T-1;
for (int j = T-1; j >=0 ; j--)
{
if (nums[j]>nums[ans])
{
ans = j; continue;
}
}
cout << "Case " << i + 1 << ": " << nums[ans]+1 << " " << ans + gjj << endl;
}
return 0;
}