rt,怀疑 read() 函数错了。
#include <stdio.h>
#define BUFSIZE 80000000
#define isdigit(x) (x > 47 && x < 58)
char buf[BUFSIZE];
int sttt = -1;
#define getchar() buf[++sttt]
#define N 50100
int x, y, a, b[N], c[N], lb, lc;
int read() {
register char c;
register int f = 1;
for (; !isdigit(c); c = getchar()) {
if (c == '-')
f = -1;
if (c == -1)
return 0;
}
for (; isdigit(c); c = getchar())
a = f * ((a << 1) + (a << 3) + (c ^ 48));
return 1;
}
main() {
fread(buf, 1, BUFSIZE, stdin);
while (read()) {
for (register int i = 1 << 15; i >= 1; i >>= 1) {
if (x + i <= lb && b[x + i] >= a)
x += i;
if (y + i <= lc && c[y + i] < a)
y += i;
}
if (++x <= lb)
b[x] = a;
else
b[++lb] = a;
if (++y <= lc)
c[y] = a;
else
c[++lc] = a;
x = y = a = 0;
}
printf("%d\n%d", lb, lc);
}