#include<iostream>
using namespace std;
int main()
{
long long n,i,s,e,a[2000],b[2000],max,cnt1,cnt2,j,t=1;
while(cin>>n)
{
if(n==-1) return 0;
for(i=1;i<=n;i++)
{
cin>>s>>e;
a[i]=s;
b[i]=e;
}
max=0;
for(i=1;i<=n;i++)
{
cnt1=0;
cnt2=0;
for(j=1;j<=n;j++)
{
if(a[i]>=a[j] && a[i]<=b[j])
cnt1++;
if(b[i]>=a[j] && b[i]<=b[j])
cnt2++;
}
if(cnt1>max) max=cnt1;
if(cnt2>max) max=cnt2;
}
cout<<"Case "<<t<<": "<<max<<endl;
t++;
}
}
It would be a great help to us, if we get a little explanation about this code.
ReplyDelete