HDU 5463 Clarke and minecraft

Source: Internet
Author: User

HDU 5463 Clarke and minecraft

 

Clarke and minecraft Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission (s): 260 Accepted Submission (s): 136



Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned into a game player of minecraft.
On that day, Clarke set up local network and chose create mode for sharing his achievements with others. Unfortunately, a naughty kid came his game. plache a few creepers in Clarke's castle! When Clarke returned his 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 was made of only one type material ). now Clarke want to know how many times he have to transport at least.
Note: Materials which has same type can be stacked, a grid can store 64 materials of same type at most. different types of materials can be transported together. clarke's bag has 4*9 = 36 grids.
Input The first line contains a number T (1 ≤ T ≤ 10) , The number of test cases.
For each test case:
The first line contains a number N , The number of items.
Then N Lines follow, each line contains two integer A, B (1 ≤ a, B ≤ 500) , A Denotes the type of material of this item, B Denotes the number of this material.
Output For each testcase, print a number, the number of times that Clarke need to transport at least.
Sample Input
232 333 332 33105 4676 3787 3098 4995 3203 4802 4448 3915 333100 499

Sample Output
12

 

A backpack has 36 grids, each of which can only contain one item, and a maximum of 64 buckets can be added.

 

 

#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include
      #include 
       
        #include 
        
         #include 
         
          #include using namespace std;int a[505];void add(){ int sum=0,t=0; for(int i=1;i<=500;i++) { if(a[i]) { sum+=a[i]/64; if(a[i]%64) sum++; while(sum>=36) t++,sum-=36; } } if(sum) t++; cout<
          
           >t; while(t--) { int n; cin>>n; memset(a,0,sizeof(a)); for(int i=0;i
           
            >s>>t; a[s]+=t; } add(); }}
           
          
         
        
       
     
    
   
  
 


 

 

 

Related Article

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.