1.

package testingTheCatcher;
/**
* FWP, Ausgew√¤hlte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 231 Testing the Catcher
* Link: http://uva.onlinejudge.org/external/2/231.html
*
* @author Patrick Bédat
* @version 1.0, 11/03/2010
*
* Method : DP
* Status : Accepted
* Runtime: 0.116
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main
{

public static void main(String... args) throws IOException
{
List<Short> incomingMissileHeights = new ArrayList<Short>();
StringBuffer output = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int tc = 1;

while(true)
{
short height = Short.parseShort(reader.readLine());

if (height != -1)
{
incomingMissileHeights.add(height);
}
else
{
if(incomingMissileHeights.size() == 0 && height == -1)
{
output.deleteCharAt(output.length()-1);
break;
}

int[] lengths = new int[incomingMissileHeights.size()];
Arrays.fill(lengths, 1);

int maxLength = 1;

if (height == -1)
{
for (int i = 0; i < incomingMissileHeights.size(); i++)
for (int j = i + 1; j < incomingMissileHeights.size(); j++)
if (incomingMissileHeights.get(i) > incomingMissileHeights.get(j) && lengths[i] + 1 > lengths[j])
{
lengths[j] = lengths[i] + 1;
maxLength = Math.max(lengths[j], maxLength);
}

output.append("Test #"+ tc++ +":\n");
output.append(" maximum possible interceptions: "+maxLength+"\n");
output.append("\n");
incomingMissileHeights.clear();
}
}
}

System.out.print(output);
}
}



2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 231 Testing the Catcher
* Link: http://uva.onlinejudge.org/external/2/231.pdf
*
* @author Barny Porcio
* @version 1.0, 07/01/2010
*
* Method : -
* Status : Accepted
* Runtime: 0.100
*/



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;

public class catcher231 {

/**
* @param args
* @throws IOException
* @throws NumberFormatException
*/
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int testcase = 1;
boolean firstcase = true;
while(true){
int first = Integer.parseInt(br.readLine());
if (first == -1)
return;
LinkedList<Integer> ll = new LinkedList<Integer>();
ll.add(first);
int temp = Integer.parseInt(br.readLine());
while (temp != -1){
ll.add(temp);
temp = Integer.parseInt(br.readLine());
}

int longest[] = new int[ll.size()];
longest[0] = 1;
int allerlaengste = 1;
for (int i = 1; i < ll.size(); ++i){
int laengstes = -1;
for (int i2 = i-1; i2 >= 0; --i2){
if (ll.get(i2)>ll.get(i) )
if (laengstes == -1 || longest[laengstes] < longest[i2])
laengstes = i2;

}
if (laengstes == -1)
longest[i] = 1;
else
longest[i] = longest[laengstes]+1;
if (longest[i] > allerlaengste )
allerlaengste = longest[i];

}
if (firstcase)
firstcase = false;
else
System.out.println();
System.out.println("Test #"+testcase+":");
System.out.println(" maximum possible interceptions: "+allerlaengste);
++testcase;

}

}

}