-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuva231.cpp
61 lines (49 loc) · 833 Bytes
/
uva231.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstring>
using namespace std;
int grade(vector<int> v)
{
int LDS[v.size()];
LDS[0] = 1;
int len = 1;
for(int i = 1; i < v.size(); i++)
{
LDS[i] = 1;
for(int j = 0; j < i; j++)
{
//daca se poate extinde secventa de lungime maxima
if(v[i] <= v[j])
LDS[i] = max(LDS[i], 1 + LDS[j]);
}
if(LDS[i] > len)
len = LDS[i];
}
return len;
}
int main()
{
vector<int> v;
int height;
int i = 1;
while(scanf("%d", &height))
{
if(height == -1)
break;
v.clear();
v.push_back(height);
while(scanf("%d", &height))
{
if(height == -1)
break;
v.push_back(height);
}
printf("Test #%d:\n", i);
printf(" maximum possible interceptions: %d\n", grade(v));
//printf("\n");
i++;
}
return 0;
}