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 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(≤T≤), 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(≤a,b≤), 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

Sample Output

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

Source
 

附上中文题目:

克拉克是一名人格分裂患者。某一天,克拉克分裂成了一个学生,在做题。
突然一道难题难到了克拉克,这道题是这样的:
给你n个数,要求选一些数(可以不选),把它们加起来,使得和恰好是p的倍数(0也是p的倍数),求方案数。
对于n很小的时候,克拉克是能轻易找到的。然而对于n很大的时候,克拉克没有办法了,所以来求助于你。

附上官方题解:

贪心,将同样材料堆到一格里,然后每一次都装满36个格子,装满就运即可。注意取上界操作。

 #pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
#include <stack>
using namespace std;
int dirx[]={,,-,};
int diry[]={-,,,};
#define PI acos(-1.0)
#define max(a,b) (a) > (b) ? (a) : (b)
#define min(a,b) (a) < (b) ? (a) : (b)
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 1000000
#define inf 1e12
int n;
map<int,int>mp; int main()
{
int t;
scanf("%d",&t);
while(t--){
mp.clear();
scanf("%d",&n);
for(int i=;i<n;i++){
int x,y;
scanf("%d%d",&x,&y);
mp[x]+=y;
} int ans=;
int g=;
for(int i=;i<=;i++){
if(mp[i]){
g+=mp[i]/;
if(mp[i]%!=){
g++;
}
}
} ans=ans+g/; if(g%!=){
ans++;
}
printf("%d\n",ans); }
return ;
}

hdu 5463 Clarke and minecraft(贪心)的更多相关文章

  1. hdu 5463 Clarke and minecraft

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5463 Clarke and minecraft Time Limit: 2000/1000 MS (J ...

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

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

  3. hdu 4825 Xor Sum(trie+贪心)

    hdu 4825 Xor Sum(trie+贪心) 刚刚补了前天的CF的D题再做这题感觉轻松了许多.简直一个模子啊...跑树上异或x最大值.贪心地让某位的值与x对应位的值不同即可. #include ...

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

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

  5. hdu 5562 Clarke and food(贪心)

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

  6. HDU 5627 Clarke and MST &意义下最大生成树 贪心

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5627 题意:Bestcoder的一道题,让你求&意义下的最大生成树. 解法: 贪心,我们从高位 ...

  7. HDU 5813 Elegant Construction (贪心)

    Elegant Construction 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer ...

  8. HDU 5802 Windows 10 (贪心+dfs)

    Windows 10 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5802 Description Long long ago, there was ...

  9. hdu 5565 Clarke and baton 二分

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

随机推荐

  1. Linux配置FTP服务器

    基于CentOS-6.5 1.先查看是否已安装:rpm -qa vsftpd 或 rpm -ql vsftpd 2.安装:yum install vsftpd -y 3.设置开机启动: chkconf ...

  2. mysql用户和权限管理

    用户和权限管理 Information about account privileges is stored in the user, db, host, tables_priv, columns_p ...

  3. 【转】多核CPU运行模式

    多核CPU运行模式主要有以下三种: •非对称多处理(Asymmetric multiprocessing,AMP)——每个CPU内核运行一个独立的操作系统或同一操作系统的独立实例(instantiat ...

  4. 图的遍历(DFS、BFS)

    理论: 深度优先搜索(Depth_Fisrst Search)遍历类似于树的先根遍历,是树的先根遍历的推广: 广度优先搜索(Breadth_First Search) 遍历类似于树的按层次遍历的过程: ...

  5. eclipse里添加类似myeclipse打开当前操作目录

    1.开打eclipse ide,依次run->external tools->external tools configuration 2.在Program下,new一个自己定义的prog ...

  6. 用window.print()打印指定div里面的内容

    用window.print()打印指定div里面的内容 今天客户让添加个打印证照功能,直接用window.print()打印的是整个页面,而用以下方法就可以只打印证明了 <!--window.p ...

  7. .NET基础拾遗(1)类型语法基础和内存管理基础1

    一.基础类型和语法 1.1 .NET中所有类型的基类是什么? 在.NET中所有的内建类型都继承自System.Object类型. 1.2 值类型和引用类型的区别? 在.NET中的类型分为值类型和引用类 ...

  8. ArcEngine颜色可视化

    AE中利用.NET中的ColorDialog对话框,将color对象转化为ArcEngine中的IRgbColor (1)在实现颜色选择之前,需定义这两种颜色之间的转换函数 //Color转换为Rgb ...

  9. 写个点击input框 下方弹出月份时间等

    <input type="text" name="test" id="test" value="" "& ...

  10. python调用ice接口

    今天用python调用ice接口,遇到如下提示 ImportError: No module named Ice 解决方案是 set PYTHONPATH=C:\Program Files\ZeroC ...