import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int i=1;
while(true){
int n=Integer.parseInt(br.readLine());
if(n<0)
break;
if(i>1)
sb.append("\n");
Vector<Integer> vec=new Vector<Integer>();
vec.add(n);
while(true){
n=Integer.parseInt(br.readLine());
if(n<0)
break;
vec.add(n);
}
sb.append("Test #").append(i).append(":\n");
sb.append(" maximum possible interceptions: ").append(LDS(vec)).append("\n");
i++;
}
System.out.print(sb);
}
static int LDS(Vector<Integer> vec){
int[]arr=new int[vec.size()];
arr[0]=1;
int maxL=0;
for(int i=1;i<arr.length;i++){
int maX=0;
for(int j=0;j<i;j++){
if(vec.get(j)>vec.get(i) &&arr[j]>maX){
maX=arr[j];
}
}
arr[i]=maX+1;
if(arr[i]>maxL){
maxL=arr[i];
}
}
return maxL;
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int i=1;
while(true){
int n=Integer.parseInt(br.readLine());
if(n<0)
break;
if(i>1)
sb.append("\n");
Vector<Integer> vec=new Vector<Integer>();
vec.add(n);
while(true){
n=Integer.parseInt(br.readLine());
if(n<0)
break;
vec.add(n);
}
sb.append("Test #").append(i).append(":\n");
sb.append(" maximum possible interceptions: ").append(LDS(vec)).append("\n");
i++;
}
System.out.print(sb);
}
static int LDS(Vector<Integer> vec){
int[]arr=new int[vec.size()];
arr[0]=1;
int maxL=0;
for(int i=1;i<arr.length;i++){
int maX=0;
for(int j=0;j<i;j++){
if(vec.get(j)>vec.get(i) &&arr[j]>maX){
maX=arr[j];
}
}
arr[i]=maX+1;
if(arr[i]>maxL){
maxL=arr[i];
}
}
return maxL;
}
}
No comments:
Post a Comment