hdu 5463 Clarke and minecraft

题目链接: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 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. He placed 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

2

3

2 33

3 33

2 33

10

5 467

6 378

7 309

8 499

5 320

3 480

2 444

8 391

5 333

100 499

Sample Output

1

2

Hint:
The first sample, we need to use 2 grids to store the materials of type 2 and 1 grid to store the materials of type 3. So we only need to transport once;

Source

BestCoder Round #56 (div.2)

题目大意:

想要和盒子搬运一些物品,每个物品都有材质和数量。,一个盒子有36个格子,每个格子只能装同一种材质的物品,一个格子最多只能装64件物品。最后输出的是需要搬运几次。

详见代码。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4
 5 using namespace std;
 6
 7 int main()
 8 {
 9     int t;
10     int sum[510];
11     scanf("%d",&t);
12     while (t--)
13     {
14         int n,Max=0,ans=0;
15         memset(sum,0,sizeof(sum));
16         scanf("%d",&n);
17         while (n--)
18         {
19             int a,b;
20             scanf("%d%d",&a,&b);
21             sum[a]+=b;//a类有多少个
22             if (a>Max)
23                 Max=a;
24         }
25         for (int i=0; i<=Max; i++)
26         {
27             if (sum[i]==0)
28                 continue;
29             if (sum[i]%64==0)
30                 ans+=sum[i]/64;
31             else
32                 ans+=(sum[i]/64)+1;
33         }
34         int aans;
35         if (ans%36==0)
36             aans=ans/36;
37         else
38             aans=(ans/36)+1;
39         printf ("%d\n",aans);
40     }
41     return 0;
42 }
时间: 2024-11-16 03:18:10

hdu 5463 Clarke and minecraft的相关文章

hdu 5463 Clarke and minecraft(贪心)

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

BestCoder Round #56/hdu5463 Clarke and minecraft 水题

Clarke and minecraft 问题描述 克拉克是一名人格分裂患者.某一天,克拉克分裂成了一个游戏玩家,玩起了minecraft.渐渐地,克拉克建起了一座城堡. 有一天,克拉克为了让更多的人分享自己的成果,开了局域网,并且选择创造模式.不幸的是,这一天有一个熊孩子进了克拉克的游戏,他在克拉克的城堡里放了很多个爬行者!当刚刚去外面打怪回.开着生存模式的克拉克回到城堡中的一瞬间,爬行者们突然自爆......(自行脑部画面)于是克拉克的城堡变成了一片废墟,圆石.木板.砖块等建筑材料撒落了一地

HDU 5465 Clarke and puzzle Nim游戏+二维树状数组

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5465 Clarke and puzzle Accepts: 42 Submissions: 269 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描述 克拉克是一名人格分裂患者.某一天,有两个克拉克(aa和bb)在玩一个方格游戏. 这个方格是一个n*mn∗m的矩阵,每个格子里有一

HDU 5464 Clarke and problem 动态规划

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5464 Clarke and problem Accepts: 130 Submissions: 781 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描述 克拉克是一名人格分裂患者.某一天,克拉克分裂成了一个学生,在做题. 突然一道难题难到了克拉克,这道题是这样的: 给你nn个数

hdu 5565 Clarke and baton 二分

Clarke and baton Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5565 Description Clarke is a patient with multiple personality disorder. One day, Clarke split into n guys, named 1 to n. They will play a game ca

hdu 5465 Clarke and puzzle 二维线段树

Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5465 Description 克拉克是一名人格分裂患者.某一天,有两个克拉克(aa和bb)在玩一个方格游戏. 这个方格是一个n*mn∗m的矩阵,每个格子里有一个数c_{i, j}c?i,j??. aa想开挂,想知道如何打败bb. 他们要玩qq次游戏,每一次做一次操作: 1. 取出当中的一

hdu 5625 Clarke and chemistry

Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned into a junior student and took a chemistry exam.  But he did not get full score in this exam. He checked his test paper and found a naive mistake, he w

hdu 5626 Clarke and points

Clarke and points Problem Description The Manhattan Distance between point A(XA,YA) and B(XB,YB) is |XA - XB| + |Xb - YB|; the coordinate of each point is generated by the followed code. Input long long seed;inline long long rand(long long l, long lo

HDU 5629 Clarke and tree dp+prufer序列

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=562 题意: 求给每个节点的度数允许的最大值,让你求k个节点能组成的不同的生成树个数. 题解: 对于n个节点形成的一颗生成树,有一个与之唯一对应的大小为n-2的prufer数列. 并且一个节点的度数减一为它出现在prufer数列中的次数. 那么我们求生成树的个数可以转化为求prufer数列的可重集排列,而这个可以用dp来做. dp[i][j][k]表示处理到第i个节点,已经用了j个节点,且可重集大小