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: ...
随机推荐
- Python多线程获取返回值
在使用多线程的时候难免想要获取其操作完的返回值进行其他操作,下面的方法以作参考: 一,首先重写threading类,使其满足调用特定的方法获取其返回值 import threading class M ...
- ROC曲线和PR曲线绘制【转】
TPR=TP/P :真正率:判断对的正样本占所有正样本的比例. Precision=TP/(TP+FP) :判断对的正样本占判断出来的所有正样本的比例 FPR=FP/N :负正率:判断错的负样本占所 ...
- java使用Cookie判断用户登录情况
1.判断是否登录 public boolean isLogin() { Set<Cookie> cookies = this.browser.getCookies(); String JS ...
- UVA12538 Version Controlled IDE
题意翻译 维护一种数据结构,资磁三种操作. 1.在p位置插入一个字符串s 2.从p位置开始删除长度为c的字符串 3.输出第v个历史版本中从p位置开始的长度为c的字符串 1≤n≤50000,所有字符串总 ...
- (转)enable_from_this方法的使用与陷阱
转自http://blog.chinaunix.net/uid-442138-id-2122464.html enable_from_this 的使用与实现原理说明: shared_from_ ...
- 【转】嵌入式Linux驱动面试题三道
题一: Linux设备中字符设备与块设备有什么主要的区别? 字符设备:字符设备是个能够像字节流(类似文件)一样被访问的设备,由字符设备驱动程序来实现这种特性.字符设备驱动程序通常至少实现open,cl ...
- 【ARC083E】Bichrome Tree
Description 给一棵\(n\)个节点的树,和一个长度同样为\(n\)的非负整数序列\(x_i\). 请尝试对每个节点染黑或白两种颜色,并确定一个非负整数权值. 问是否存在一种方案 ...
- 微信开发使用 frp 实现本地测试
前提条件: 1.有公网服务器(如阿里云) 2.需要独立的 80 端口,也就是说,想要实现这个目标,服务器上不能跑 nginx 之类占用 80 端口的程序 3.有可以测试使用的域名,并解析到上面说的公网 ...
- P2306 被yyh虐的mzc
P2306 被yyh虐的mzc 容量为 \(V\), 有 \(n\) 件物品, 反正直接背包绝对超时 , 每个有重量和价值 \(a_{i}, b_{i}(a_{i}, b_{i} <= 10)\ ...
- java中的悲观锁和乐观锁实现
悲观锁就是认为并发时一定会有冲突发生,采用互斥的策略.比如java中的synchronized. 而乐观锁是假设并发时不会有冲突发生,如果发生冲突,则操作失败,并不断重试.乐观锁的机制就是CAS(Co ...