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
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.
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.
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;
#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的更多相关文章
- hdu 5463 Clarke and minecraft(贪心)
Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke turned i ...
- HDU 5628 Clarke and math——卷积,dp,组合
HDU 5628 Clarke and math 本文属于一个总结了一堆做法的玩意...... 题目 简单的一个式子:给定$n,k,f(i)$,求 然后数据范围不重要,重要的是如何优化这个做法. 这个 ...
- BestCoder Round #56/hdu5463 Clarke and minecraft 水题
Clarke and minecraft 问题描述 克拉克是一名人格分裂患者.某一天,克拉克分裂成了一个游戏玩家,玩起了minecraft.渐渐地,克拉克建起了一座城堡. 有一天,克拉克为了让更多的人 ...
- hdu 5565 Clarke and baton 二分
Clarke and baton Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- 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 ...
- hdu 5465 Clarke and puzzle 二维线段树
Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- hdu 5464 Clarke and problem dp
Clarke and problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php ...
- HDU 5628 Clarke and math dp+数学
Clarke and math 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5628 Description Clarke is a patient ...
- HDU 5464 Clarke and problem 动态规划
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5464 Clarke and problem Accepts: 130 Submissions: ...
随机推荐
- 父类是在子类创建对象时候 在子类中创建一个super内存空间
父类是在子类创建对象时候 在子类中创建一个super内存空间
- SQLServer 重建索引前后对比 (转)
https://www.cnblogs.com/mingl12/p/5730178.html
- nginx实现ldap认证
1.安装依赖. yum -y install openldap-devel yum install pcre pcre-devel -y yum -y install openssl openssl- ...
- Leetcode模拟题篇
43. Multiply Strings 高精度非负整数的乘法. string multiply(string num1, string num2) { '); ; <= i; --i) { ; ...
- redis动态扩展内存
需求:将redis内存从1G扩展到3G,不中断服务 1.打开客户端 # redis-cli -p 6391 2.查看当前值 redis 127.0.0.1:6391> config get ma ...
- 书架 bookshelf
书架 bookshelf 题目描述 当Farmer John闲下来的时候,他喜欢坐下来读一本好书. 多年来,他已经收集了N本书 (1 <= N <= 100,000). 他想要建立一个多层 ...
- laravel mapSpread 例子
$collection = collect(range(1, 9)); $chunks = $collection->chunk(2); $labeld = $chunks->mapSpr ...
- config配置中心之自动刷新
自动刷新(自动刷新是基于springcloudbus来实现的,springcloud bus是基于rabbitMQ或者Kafka来实现的) Spring Cloud Bus 将分布式的节点用轻量的消息 ...
- web项目中的执行流程参数传递详解
还是从这个图开始讲解: struts2中有一个存放数据的中心:值栈.(值栈里面有map和对象栈) 首先:值栈的作用范围是一个请求:request作用域(一个请求是代表的一个过程,即页面点击到数据返回到 ...
- UVAL 7902 2016ECfinal F - Mr. Panda and Fantastic Beasts
题意: 给出n个串,求一个最短的第一个串的子串使它不在其他的n-1个串中出现,若有多个求字典序最小的. Limits: • 1 ≤ T ≤ 42. • 2 ≤ N ≤ 50000. • N ≤ S1 ...