首页 > 代码库 > 贪心/Hdu 1050 Moving Tables

贪心/Hdu 1050 Moving Tables

#include<cstdio>#include<cstring>using namespace std;int a[220];int cmax(int a,int b){return a>b?a:b;}int main(){    int T;    scanf("%d",&T);    for (int t=1;t<=T;t++)    {        int n;        scanf("%d",&n);        int x,y,xx,yy;        int ans=0;        memset(a,0,sizeof(a));        for (int i=1;i<=n;i++)        {            scanf("%d%d",&x,&y);            xx=(x+1)/2;yy=(y+1)/2;            if (xx>yy)            {                int tt=xx;                xx=yy;                yy=tt;            }            for (int j=xx;j<=yy;j++)            {                a[j]++;                ans=cmax(ans,a[j]);            }        }        printf("%d\n",ans*10);    }    return 0;}

 

贪心/Hdu 1050 Moving Tables