题目链接: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
 
题目大意:
想要和盒子搬运一些物品,每个物品都有材质和数量。,一个盒子有36个格子,每个格子只能装同一种材质的物品,一个格子最多只能装64件物品。最后输出的是需要搬运几次。
 
详见代码。
 #include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int main()
{
int t;
int sum[];
scanf("%d",&t);
while (t--)
{
int n,Max=,ans=;
memset(sum,,sizeof(sum));
scanf("%d",&n);
while (n--)
{
int a,b;
scanf("%d%d",&a,&b);
sum[a]+=b;//a类有多少个
if (a>Max)
Max=a;
}
for (int i=; i<=Max; i++)
{
if (sum[i]==)
continue;
if (sum[i]%==)
ans+=sum[i]/;
else
ans+=(sum[i]/)+;
}
int aans;
if (ans%==)
aans=ans/;
else
aans=(ans/)+;
printf ("%d\n",aans);
}
return ;
}

hdu 5463 Clarke and minecraft的更多相关文章

  1. hdu 5463 Clarke and minecraft(贪心)

    Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned i ...

  2. HDU 5628 Clarke and math——卷积,dp,组合

    HDU 5628 Clarke and math 本文属于一个总结了一堆做法的玩意...... 题目 简单的一个式子:给定$n,k,f(i)$,求 然后数据范围不重要,重要的是如何优化这个做法. 这个 ...

  3. BestCoder Round #56/hdu5463 Clarke and minecraft 水题

    Clarke and minecraft 问题描述 克拉克是一名人格分裂患者.某一天,克拉克分裂成了一个游戏玩家,玩起了minecraft.渐渐地,克拉克建起了一座城堡. 有一天,克拉克为了让更多的人 ...

  4. hdu 5565 Clarke and baton 二分

    Clarke and baton Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  5. hdu 5563 Clarke and five-pointed star 水题

    Clarke and five-pointed star Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/show ...

  6. hdu 5465 Clarke and puzzle 二维线段树

    Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  7. hdu 5464 Clarke and problem dp

    Clarke and problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php ...

  8. HDU 5628 Clarke and math dp+数学

    Clarke and math 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5628 Description Clarke is a patient ...

  9. HDU 5464 Clarke and problem 动态规划

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5464 Clarke and problem  Accepts: 130  Submissions: ...

随机推荐

  1. SpringBoot(四)_Spring Data JPA的使用

    JPA 绝对是简化数据库操作的一大利器. 概念 首先了解 JPA 是什么? JPA(Java Persistence API)是 Sun 官方提出的 Java 持久化规范.它为 Java 开发人员提供 ...

  2. toast components

    toast components https://jossmac.github.io/react-toast-notifications/ https://docs.microsoft.com/en- ...

  3. cnblog博客CSS定制

    一.页面定制CSS #home { margin: 0 auto; width: 80%;/*原始65*/ min-width: 980px;/*页面顶部的宽度*/ background-color: ...

  4. CSS实现点击改变元素背景色

    可通过使用css伪类实现点击元素变色的效果,两个伪类是:active, :focus :active :active选择器用于选择活动链接.当在一个链接上点击时,它就会成为活动的(激活的),:acti ...

  5. CSU1392(NCPC2013)_Number Trick

    给一个小数X,找个A使得:AX=(A循环左移一位) 首先,假设A为一个满足题目条件的数,有n个数位,且最高位数字为A0. 那么可列出方程:AX=(A-A0*10n-1)*10+A0 ————>& ...

  6. LINQ 学习之筛选条件

       从list 里遍历出 id="DM" 且 code="0000" 的数据 var tes1= from u in list.where u.ID == & ...

  7. MT【135】条件线性化

    已知\(x,y>0,\dfrac{1}{x}+\dfrac{2}{y}=1\),求\(\dfrac{1}{x+1}+\dfrac{2}{y+1}\)的最大值_____ 解答:令\(a=\dfra ...

  8. [USACO12NOV]同时平衡线Concurrently Balanced Strings DP map 思维

    题面 [USACO12NOV]同时平衡线Concurrently Balanced Strings 题解 考虑DP. \(f[i]\)表示以\(i\)为左端点的合法区间个数.令\(pos[i]\)表示 ...

  9. win7右下角的同步中心怎么去除

    “开始”-“运行”-“regedit”,在“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Syncmgr\Handlers” ...

  10. 【转】rt-thread的位图调度算法分析

    序言 期待读者 本文期待读者有C语言编程基础,后文中要分析代码,对其中的一些C语言中的简单语句不会介绍,但是并不要求读者有过多的C基础,比如指针和链表等不会要求太多,后面在分析代码时,会附带地介绍相关 ...