#include <cstdio>
#include<iostream>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<string.h>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
double price[35];
double limit;
int size;
double ans;
void dfs(int x,double cost)
{
if(cost>limit)
return;
if(x==size)
{
if(cost>ans)
ans=cost;
return;
}
dfs(x+1,cost+price[x]);
dfs(x+1,cost);
}
int main()
{
int n;
while(cin>>limit>>n)
{
if(n==0)
break;
size=0;
ans=-1;
while(n--)
{
int m;
cin>>m;
bool flag=true;
double sum=0;
for(int i=0;i<m;i++)
{
char c,cc;
double cost;
cin>>c>>cc;
cin>>cost;
if(c!='A'&&c!='B'&&c!='C')
flag=false;
if(cost>600)
flag=false;
sum+=cost;
}
if(flag&&sum<=1000)
price[size++]=sum;
}
dfs(0,0);
printf("%.2f\n",ans);
}
return 0;
}
/**************************************************************
Problem: 1025
User: cust123
Language: C++
Result: Accepted
Time:10 ms
Memory:1520 kb
****************************************************************/
题目1025:最大报销额
最新推荐文章于 2024-05-31 21:56:15 发布