HDU 5463Clarke and minecraft

Clarke and minecraft

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 260    Accepted Submission(s): 136

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

水题,有一个背包有36个格子  每个格子只能放一种物品,且最多只能叠加64个  问要多少次才能将物品运完

#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int a[505];

void add()
{
    int sum=0,t=0;
    for(int i=1;i<=500;i++)
    {
        if(a[i])
        {
            sum+=a[i]/64;
            if(a[i]%64) sum++;
            while(sum>=36)
                t++,sum-=36;
        }
    }
    if(sum) t++;
    cout<<t<<endl;
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        memset(a,0,sizeof(a));
        for(int i=0;i<n;i++)
        {
            int s,t;
            cin>>s>>t;
            a[s]+=t;
        }
        add();
    }
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-11-10 18:37:46

HDU 5463Clarke and minecraft的相关文章

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 Problem Description Clarke is a patien

hdu 5463 Clarke and minecraft(贪心)

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

hdu 5279 YJC plays Minecraft——生成函数

题目:http://acm.hdu.edu.cn/showproblem.php?pid=5279 令 n 个点的树的 EGF 是 g(x) ,则 \( g(x) = \sum\limits_{i=0}^{\infty} \frac{i^{i-2}}{i!} x^i \) 令 n 个点的森林的 EGF 是 f(x) ,则 \( f(x) = \sum\limits_{i=0}^{\infty} \frac{g(x)^i}{i!} = e^{g(x)} \) 这道题里,每个团调用 f(x) 的对应

HDU 5279 YJC plays Minecraft (分治NTT优化DP)

题目传送门 题目大意:有$n$个小岛,每个小岛上有$a_{i}$个城市,同一个小岛上的城市互相连接形成一个完全图,第$i$个小岛的第$a_{i}$个城市和第$i+1$个小岛的第$1$个城市连接,特别地,第$n$个小岛的第$a_{n}$个城市和第$1$个小岛的第$1$个城市连接.现在要断掉图中的一些边,保证任意两个城市只有一条路径或者不连通,求合法的断边方案总数,$n,a_{i}<=1e5$ 完全不会(喷血 我们对每个小岛单独讨论 如果任意两个城市只有一条路径或者不连通,那么这张图只能是一个森林

HDU 5538 House Building(模拟——思维)

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5538 Problem Description Have you ever played the video game Minecraft? This game has been one of the world's most popular game in recent years. The world of Minecraft is made up of lots of 1×1×1 blocks

hdu 5538 House Building(长春现场赛——水题)

题目链接:acm.hdu.edu.cn/showproblem.php?pid=5538 House Building Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 621    Accepted Submission(s): 398 Problem Description Have you ever played the vid

HDU 6203 ping ping ping [LCA,贪心,DFS序,BIT(树状数组)]

题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=6203] 题意 :给出一棵树,如果(a,b)路径上有坏点,那么(a,b)之间不联通,给出一些不联通的点对,然后判断最少有多少个坏点. 题解 :求每个点对的LCA,然后根据LCA的深度排序.从LCA最深的点对开始,如果a或者b点已经有点被标记了,那么continue,否者标记(a,b)LCA的子树每个顶点加1. #include<Bits/stdc++.h> using namespace std;

HDU 5542 The Battle of Chibi dp+树状数组

题目:http://acm.hdu.edu.cn/showproblem.php?pid=5542 题意:给你n个数,求其中上升子序列长度为m的个数 可以考虑用dp[i][j]表示以a[i]结尾的长度为j的上升子序列有多少 裸的dp是o(n2m) 所以需要优化 我们可以发现dp的第3维是找比它小的数,那么就可以用树状数组来找 这样就可以降低复杂度 #include<iostream> #include<cstdio> #include<cstring> #include

hdu 1207 汉诺塔II (DP+递推)

汉诺塔II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4529    Accepted Submission(s): 2231 Problem Description 经典的汉诺塔问题经常作为一个递归的经典例题存在.可能有人并不知道汉诺塔问题的典故.汉诺塔来源于印度传说的一个故事,上帝创造世界时作了三根金刚石柱子,在一根柱子上从下往