# CSUOJ 1900 锋芒不露

## Sample Input

3
2 8
3 1
1 4

3
1 1
2 2
3 3

0

## Sample Output

10
10
9

2
3
4

Hint

#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int l[105], r[105];
int main()
{
int T,a,b;
while (~scanf("%d", &T))
{
if (!T)
break;
memset(l, 0, sizeof(l));
memset(r, 0, sizeof(r));
int maxx=100,minn=0;
for (int i = 1; i <= T; i++)
{
scanf("%d%d", &a, &b);
l[a]++, r[b]++;
if (maxx>a)maxx = a;
if (minn < b)minn = b;
int m = maxx, n = minn,ma=0;
int p = l[maxx], q = r[minn];
int cnt = 0;
while (cnt != i)
{
if (p == 0)
{
p = l[++m];
continue;
}
if (q == 0)
{
q = r[--n];
continue;
}
if (m + n > ma)ma = m + n;
if (p == q)
{
cnt += p; m++; n--;
p = l[m]; q = r[n];
}
else if (p < q)
{
q -= p;
cnt += p;
p = l[++m];
}
else if (p>q)
{
p -= q;
cnt += q;
q = r[--n];
}
}
printf("%d\n", ma);
}
printf("\n");
}
}
/**********************************************************************
Problem: 1900
User: leo6033
Language: C++
Result: AC
Time:444 ms
Memory:2024 kb
**********************************************************************/