hdu 5463(水水)

 

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 Hint: 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;

 

 


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


#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;

int p[1000];
const int inf = 0x3f3f3f3f;
int main()
{
    int T,n,a,b;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        memset(p,0,sizeof(p));
        int tmax = 0;
        for(int i = 1;i <= n;i++)
        {
            scanf("%d%d",&a,&b);
            p[a] += b;
            if(tmax < a)
                tmax = a;
        }
        int ans = 0;
        for(int i = 1;i <= tmax;i++)
        {
            if(p[i])
            {
                ans += p[i]/64;
                if(p[i] % 64)
                    ans++;
            }
        }
        if(ans % 36)
        printf("%d\n",ans/36 + 1);
        else
            printf("%d\n",ans/36);
    }
    return 0;
}

  

转载于:https://www.cnblogs.com/Przz/p/5409744.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值