You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
780 B
34 lines
780 B
// http://poj.org/problem?id=1887
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
const int N = 200010;
|
|
const int INF = 1e8;
|
|
|
|
int n;
|
|
int a[N];
|
|
int g[N];
|
|
int kase;
|
|
|
|
int main() {
|
|
while (scanf("%d", &a[1]) == 1 && ~a[1]) {
|
|
if (kase) puts("");
|
|
n = 2;
|
|
|
|
while (scanf("%d", &a[n]) == 1 && a[n] != -1) n++;
|
|
n--;
|
|
|
|
reverse(a + 1, a + n + 1);
|
|
for (int i = 1; i <= n; i++) g[i] = INF;
|
|
|
|
int ans = 0;
|
|
for (int i = 1; i <= n; i++) {
|
|
int k = lower_bound(g + 1, g + n + 1, a[i]) - g;
|
|
g[k] = a[i];
|
|
ans = max(ans, k);
|
|
}
|
|
printf("Test #%d:\n maximum possible interceptions: %d\n", ++kase, ans);
|
|
}
|
|
return 0;
|
|
} |