-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing the catcher.cpp
58 lines (55 loc) · 1016 Bytes
/
testing the catcher.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
55
56
57
58
#include<bits/stdc++.h>
using namespace std;
#define mx 10000
int dp[mx],n;
int value[mx];
int longest(int u)
{
if(dp[u]!=-1)
return dp[u];
int maxi=0;
for(int v=u+1;v<n;v++)
{
if(value[v]<=value[u])
{
int x=longest(v);
if(x>maxi)
{
maxi=x;
}
}
}
return dp[u]=maxi+1;
}
int main()
{
bool start=false;
int testcase=0,x,i;
n=0;
while(cin>>x)
{
if(x==-1)
break;
if(start)
cout<<endl;
start=true;
value[n++]=x;
while(cin>>x)
{
if(x==-1)
break;
value[n++]=x;
}
memset(dp,-1,sizeof dp);
int lis=0,z;
for(i=0;i<n;i++)
{
z=longest(i);
if(z>lis)
lis=z;
}
cout<<"Test #"<<++testcase<<":\n";
cout<<" maximum possible interceptions: "<<lis<<endl;
n=0;
}
}