hdu 5463 Clarke and minecraft(BestCoder Round #56 (div.2))

Clarke and minecraft

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 314    Accepted Submission(s): 163


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(1T10), 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(1a,b500) 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;

翻译:

问题描述
克拉克是一名人格分裂患者。某一天,克拉克分裂成了一个游戏玩家,玩起了minecraft。渐渐地,克拉克建起了一座城堡。  
有一天,克拉克为了让更多的人分享自己的成果,开了局域网,并且选择创造模式。不幸的是,这一天有一个熊孩子进了克拉克的游戏,他在克拉克的城堡里放了很多个爬行者!当刚刚去外面打怪回、开着生存模式的克拉克回到城堡中的一瞬间,爬行者们突然自爆......(自行脑部画面)于是克拉克的城堡变成了一片废墟,圆石、木板、砖块等建筑材料撒落了一地。  
无奈的克拉克只好拾起这些废墟,准备重建。克拉克建了足够的箱子后,想自己把这些散落的材料都搬运道箱子里。克拉克清楚的记得自己建的每一个东西当初用了多少材料以及材料的种类。现在克拉克想知道,克拉克至少需要搬运多少次,才能将所有的材料全部搬到箱子里。  
注:材料可以堆叠,一个格子最多可以容纳64个相同材料。不同物品的材料可以在一次运输到箱子中。minecraft中背包栏一共有4*9=36个格子。  
输入描述
第一行一个整数T(1 \le T \le 10)T(1T10),表示数据的组数。  
每组数据第一行是一个正整数n(1 \le n \le 100)n(1n100),表示东西的数量。  
接下来nn行,每一行有两个正整数a, b(1 \le a, b \le 500)a,b(1a,b500)aa表示这个东西的材料的种类,bb表示这种材料的数量。  
输出描述
对于每组数据,输出一个整数,表示克拉克至少搬运的次数。 

解题思路:

据说是贪心,可是我不知道耶做出来了,但是在第一次做的时候,忽略了范围:

1<= a, b <=500,注意是 <=500,可以取到500,就这个事情把我给坑了,还好另一个题过了,

rating没有掉,要不然我该哭了。。。。

现在说转入正题,就是用一个数组记一下同样的种类,先去除一下64, 然后再去判断36个格子

能不能装得下, 再然后就是输出解果了/。。。

上代码:

/**
2015 - 09 - 20 晚上

Author: ITAK

Motto:

今日的我要超越昨日的我,明日的我要胜过今日的我,
以创作出更好的代码为目标,不断地超越自己。
**/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
const int maxn = 505;
const double eps = 1e-7;

int arr[maxn];
int main()
{
    int T, m, a, b;
    cin>>T;
    while(T--)
    {
        memset(arr, 0, sizeof(arr));
        cin>>m;
        while(m--)
        {
            cin>>a>>b;
            arr[a] += b;
        }
        int sum = 0;
        for(int i=0; i<=500; i++)
        {
            if(arr[i])
            {
                if(arr[i]%64 == 0)
                    sum += arr[i]/64;
                else
                    sum += arr[i]/64+1;
            }
        }
        if(sum%36 == 0)
            sum /= 36;
        else
            sum = sum/36+1;
        cout<<sum<<endl;
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值