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. Unity重要的函数

    Awake 当一个脚本实例被载入时Awake被调用. Start Start仅在Update函数第一次被调用前调用. Update 当MonoBehaviour启用时,其Update在每一帧被调用. ...

  2. 关于打开Eclipse时出现eclipse failed to create the java virtual machine与locking is not possible in the directory问题的解决

    今天在机子上使用Eclipse时候打开发现这两个问题,通过查阅资料膜拜大神博客得知解决方法,特此整理下来,方便后来遇到此问题的小伙伴们. 一开始打开Eclipse时候出现问题现象1,问题1解决以后就出 ...

  3. android滑动基础篇 TouchView

    效果图: 代码部分: activity类代码: package com.TouchView; import android.app.Activity; import android.os.Bundle ...

  4. SVN版本分支合并

    SVN,开发中常用的工具,也没什么可说的.这里只是记录一下,以免太久不用了想用的时候又忘了. 首先已经有两个目录,一个是分支目录SVNChild,一个是主干目录SVNMain.SVNChild是从SV ...

  5. javascript 继承机制设计思想

    作者: 阮一峰 原文链接:http://www.ruanyifeng.com/blog/2011/06/designing_ideas_of_inheritance_mechanism_in_java ...

  6. chroot 与 jail

    所谓“监牢”就是指通过chroot机制来更改某个进程所能看到的根文件夹,即将某进程限制在指定文件夹中,保证该进程仅仅能对该文件夹及其子文件夹的文件有所动作,从而保证整个server的安全. 创建chr ...

  7. Linux命令之nano -

    我使用过的Linux命令之nano - 比vi简单易用的文本编辑器 本文链接:http://codingstandards.iteye.com/blog/802593   (转载请注明出处) 用途说明 ...

  8. HTML与CSS入门——第二章 发布Web内容

    知识点: 1.使用文本编辑器创建一个基本的HTML文件的方法 2.使用FTP将文件传送到你的Web服务器的方法 3.文件在Web服务器上应该存储的位置 4.在没有Web服务器的情况下分发Web内容的方 ...

  9. box-shadow实例1

    实例一: 1.html <div class="paddingMiddle"> <div class="blank"></div& ...

  10. React-Native OpenGL体验一

    昨天初体验了一把SVG一个并不是多么复杂的动画,我在iOS模拟器上体验的是流畅的,但是在Android真机上体验,还是比较卡的. 下面来介绍一个OpenGL的第三方库: 下面是我运行的里面Demo的效 ...