Hihocoder Buy Snacks

Source: Internet
Author: User

Buy snacks Time limit:5000MS Memory Limit:262144KB 64bit IO Format:%lld &%llu Submit Sta Tus Practice Hihocoder 1272

Description

Little Ho likes to buy snacks at the grocery store during recess. Unfortunately, this semester he was in a teaching class, and a teacher's canteen sister is famous for Frosty. The first time to a teaching kiosk to buy snacks, small ho because not sensible bought a lot of things, was the canteen sister gave a "frosty" eyes, appetite has dropped a lot.

Since then, Little Ho School, go to the grocery store to buy things only dare to buy 3 packs of snacks, and the price must be 5 of the integer times , convenient canteen sister calculate the price.

But little Ho is not good at calculating, so he put all the snacks in the store price and his desire for this snack to tell you, I hope you can help him to calculate the premise of not annoy the store sister, can buy snacks of the desire and the highest is how much.

Input

Each input file contains multiple sets of test data, the first behavior of each input file is an integer q, which represents the number of groups of test data.

The first behavior of each set of test data is a positive integer n, which indicates the number of snacks in the kiosk.

The next n rows, each acting a positive real number A and a positive integer b, represent the price of the snack and the desire of small ho for it.

A snack has only one pack.

For 100% data, 1 <= Q <= 10,1<=n<=50,0<a<=10,1<=b<=100 are satisfied.

For 100% of the data, the decimal portion of a can only be 0.5 or 0.

Output

For each set of test data, output an integer ans, indicating that little ho can get the maximum desired degree of sum.

Sample Input

1
4
0.5 6
4.5 7
5.0 4
2.0 9

Sample Output

17


This problem at first glance is the movement of rules, I learned the rules, despair, Baidu find violence also OK


But there's a simple mistake.

Floating-point type can not take the surplus, that is to do ·

Find the array int qian[i]

Multiply double by 10 and assign to Qian[i]

#include <stdio.h> int max (int a,int b) {if (a>=b) return A;
else return B;
    } struct node {double A;
int b;
}LS[55];
int qian[105];
    int main () {int q;
    scanf ("%d", &q);
        while (q--) {int n,ans=0;
        scanf ("%d", &n);
            for (int i=1;i<=n;i++) {scanf ("%lf%d", &ls[i].a,&ls[i].b);
        QIAN[I]=10*LS[I].A;
        } for (int i=1;i<=n;i++) {if (qian[i]%50==0) {Ans=max (ans,ls[i].b);} } for (int i=1;i<=n;i++) {for (int j=i+1;j<=n;j++) {if (Qi
            AN[I]+QIAN[J])%50==0) {Ans=max (ans,ls[i].b+ls[j].b);}
                }} for (int i=1;i<=n;i++) {for (int j=i+1;j<=n;j++) {
                  for (int k=j+1;k<=n;k++) {if ((Qian[i]+qian[j]+qian[k])%50==0)      {Ans=max (ans,ls[i].b+ls[j].b+ls[k].b);}
    }}} printf ("%d\n", ans); }
}


Under the regulation of the above, online looking for, first code live, stay to digest after


[CPP] view plain copy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.