Hdu 5463 Clarke and Minecraft

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5463

Clarke and Minecraft

Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 366 Accepted Submission (s): 193


Problem Descriptionclarke is a patient with multiple personality disorder. One day, Clarke turned to a game player of Minecraft.
On this day, Clarke sets up the local network and chose create mode for sharing he achievements with others. Unfortunately, a naughty kid came his game. He placed a few creepers in Clarke ' s castle! When Clarke returned he castle without create mode, Creepers suddenly blew (what a amazing scene!). Then Clarke's castle in ruins, the materials scattered over the ground.
Clark had no choice but to pick up these ruins, ready to rebuild. After Clarke built some chests (boxes), He had to pick up the material and stored them in the chests. Clarke clearly remembered the type and number of each item (each item is made of only one type material). Now Clarke want to know how many times he has to transport at least.
Note:materials which have same type can be stacked, a grid can store up to materials of same type at the most. Different types of materials can be transported together. Clarke ' s bag has 4*9=36 grids.

Inputthe First line contains a numberT(1≤t≤) , the number of test cases.
For each test case:
The first line contains a numberN, the number of items.
ThenNLines follow, each line contains the integera,b(1≤a,b≤) , a denotes the type of material of this item, and b denotes the number of this material.

Outputfor each testcase, print a number, and the number of times that Clarke need to transport at least.

Sample Input232 333 332 33105 4676 3787 3098 4995 3203 4802 4448 3915 333100 499

Sample Output12 Hint:the First sample, we need to use 2 grids to store the materials of type 2 and 1 grids to store the mat Erials of Type 3. So we only need to transport once;

Sourcebestcoder Round #56 (Div.2) topic: Want to carry some items with the box, each item has material and quantity. , a box has 36 compartments, each of which can only be loaded with one material, and a lattice can only fit up to 64 items. The final output is the need to be transported several times. See the code.
1#include <iostream>2#include <cstdio>3#include <cstring>4 5 using namespacestd;6 7 intMain ()8 {9     intT;Ten     intsum[510]; Onescanf"%d",&t); A      while(t--) -     { -         intn,max=0, ans=0; thememset (SUM,0,sizeof(sum)); -scanf"%d",&n); -          while(n--) -         { +             intb; -scanf"%d%d",&a,&b); +Sum[a]+=b;//how many of Class A have A             if(a>Max) atmax=A; -         } -          for(intI=0; i<=max; i++) -         { -             if(sum[i]==0) -                 Continue; in             if(sum[i]% -==0) -ans+=sum[i]/ -; to             Else +ans+= (sum[i]/ -)+1; -         } the         intAans; *         if(ans% $==0) $aans=ans/ $;Panax Notoginseng         Else -Aans= (ans/ $)+1; theprintf ("%d\n", Aans); +     } A     return 0; the}

Hdu 5463 Clarke and Minecraft

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.