题目链接:http://acm.tzc.edu.cn/acmhome/game.do?&method=gameProblemDetail&gameId=1&levelId=3&number=2
#include <iostream>
#include<cstdio>
using namespace std;
int main()
{ int n,m,i,j,s,r,max,temp;
cin>>n;
getchar();
while(n--)
{ int stable[200]={0};
max=0;
cin>>m;
for(i=1;i<=m;i++)
{
scanf("%d%d",&s,&r);
s=(s+1)/2;
r=(r+1)/2;
if(s>r)
{
temp=s;
s=r;
r=temp;
}
for(j=s;j<=r;j++)
{
stable[j]+=1;
}
}
for(i=0;i<200;i++)
{
if(stable[i]>max) max=stable[i];
}
cout<<10*max<<endl;
}
return 0;
}
注意:
if(s>r)
{
temp=s;
s=r;
r=temp;
}
没判断提交会WA。此题用贪心算法