1052: Maximum reimbursement time limit: 1 Sec memory limit: MB
Submitted by: 390 Resolution: 290
Submitted State [Discussion Version] The title describes a certain amount of invoices that can be reimbursed for an existing provision. The types of invoices that are allowed to be reimbursed include buying books (Class A), stationery (category B), travel (class C), requiring that the total amount of each invoice not exceed $1000, and the value of individual items on each invoice shall not exceed 600 yuan. You are now asked to write a procedure to find out the maximum amount of reimbursement that can be reimbursed, not exceeding a given amount, in a given pile of invoices. The input test input contains several test cases. The 1th line of each test case contains two positive numbers q and N, where Q is the given reimbursement amount, and N (n<=30) is the number of invoice sheets. followed by the N-line input, with the format of each line:
M type_1:price_1 type_2:price_2 ... Type_m:price_m
Where the positive integer m is the number of items opened on this invoice, type_i and Price_i are the categories and values of item I. The item type is indicated by an uppercase English letter. When n is 0 o'clock, all input ends and the corresponding result is not output. The output outputs 1 rows per test case, which is the maximum amount that can be reimbursed, and is accurate to 2 digits after the decimal point. Sample input
200.00 a:23.50 b:100.001 c:650.003 a:59.99 a:120.00 x:10.001200.00 all b:600.00 a:400.001 c:200.501200.50 + B:600.00 A: 400.001 c:200.501 a:100.00100.00 0
Sample output
123.501000.001200.50
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace Std;
int main () {
Double q;
int n;
while (cin>>q>>n&&n!=0) {
int i,j,m;
Char type[31][101][2];
Double price[31][101],count[31]={},sum=0;
for (i=1;i<=n;i++) {
cin>>m;
for (j=1;j<=m;j++) {
cin>>type[i][j][0]>>type[i][j][1];
cin>>price[i][j];
COUNT[I]=COUNT[I]+PRICE[I][J];
}
if (type[i][m][0]> ' C ') {//if type[i][][0] is not a type that contains all of the second array?
count[i]=0;
}
}
for (i=1;i<n;i++) {
for (j=i+1;j<=n;j++) {
if (Count[i]>count[j]) {
Double T=count[i];
COUNT[I]=COUNT[J];
count[j]=t;
}
}
}
for (i=n;i>0;i--) {
if (Q>=count[i]) {
Sum=sum+count[i];
Q=q-count[i];
}
}
Cout<<fixed<<setprecision (2) <<sum<<endl;
}
}
1052: Maximum Reimbursement amount