HDU 5463 Clarke and minecraft

简单贪心

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxm=505;
int a[maxm],b[maxm];
int vis[maxm];
int n;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        memset(vis,0,sizeof(vis));
        scanf("%d",&n);
        int cnt=0;
        int z=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d%d",&a[i],&b[i]);
            vis[a[i]]+=b[i];
        }
        sort(a,a+n);
        int m=unique(a,a+n)-a;
        for(int i=0;i<m;i++)
        {
            if(vis[a[i]]%64==0)
            {
                cnt+=vis[a[i]]/64;
            }
            else
            {
                cnt+=(vis[a[i]]/64)+1;
            }
        }
        if(cnt%36==0)
        {
            z+=cnt/36;
        }
        else
        {
            z+=(cnt/36)+1;
        }
        printf("%d\n",z);
    }
    return 0;
}


你可能感兴趣的:(HDU 5463 Clarke and minecraft)