--hdu 1050 Moving Tables(贪心)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050

AC code:

#include<stdio.h>
#include<string.h>
int m[210];
int main(void)
{
    int t,n,i,j,st,en,ma;
    scanf("%d",&t);
    while(t--)
    {
        memset(m,0,sizeof(m));
        scanf("%d",&n);
        for(i=0; i<n; i++)
        {
            scanf("%d%d",&st,&en);
            st=(st-1)/2;
            en=(en-1)/2;
            if(st>en)
            {
                en^=st;
                st^=en;
                en^=st;
            }
            for(j=st; j<=en; j++)
            {
                m[j]++;
            }
        }
        ma=0;
        for(i=0; i<200; i++)
        {
            ma=ma>m[i]?ma:m[i];
        }
        printf("%d
",ma*10);
    }
    return 0;
}

  

原文地址:https://www.cnblogs.com/A--Q/p/5724116.html