title: Runtime error in UVA Online Judge
body: <p>I'm doing problem 10003 "cutting sticks" of the UVa online judge, I'm pretty sure my code works and I think I' correctly exiting the problem. But still I get a runtime error, I read somewhere that is because I'm not exiting the application like I'm supposed to do it. I wish you guys can help me with this problem.</p>
  
  <pre><code>import java.io.*;
  class MAIN {
  
      static int len, c, min;
      static int mat[][] = new int[52][52];
      static int arr[] = new int [52];
      static BufferedReader BufferReader = new BufferedReader(new InputStreamReader(System.in));
      public static void llenaarr()throws IOException{
              for(int i=0; i&lt;c-1; i++) {
                      arr[i+1] = Integer.parseInt(BufferReader.readLine());
                      }
              arr[0] = 0;
              arr[c] = len;
              }
      public static void llenamat(){
              for(int i=0; i&lt;=c; i++) {
                      for(int j=0;j&lt;=c;j++) {
                              mat[i][j] = Integer.MAX_VALUE;
                              }
                      }
              for(int i=0; i&lt;c; i++) {
                      mat[i][i] = 0;
                      mat[i][i+1] = 0;
                      }
              mat[c][c] = 0;
              for(int i=0; i&lt;c-1; i++) {
                      mat[i][i+2] = arr[i+2] - arr[i];
                      }
              }
      public static void minimo(){
              for(int k=3; k&lt;=c; k++) {
                      for(int i=0; i&lt;=c-k; i++) {
                              for(int j=i+1; j&lt;=i+k-1; j++) {
                                      min=mat[i][j] + mat[j][i+k] + arr[i+k] - arr[i];
                                      if((min&lt; mat[i][i+k])) {
                                              mat[i][i+k] = min;
                                              }
                                      }
                              }
                      }
              }
  
      public static void main (String args[]) throws IOException {
              while((len = Integer.parseInt(BufferReader.readLine())) &gt; 0){
                      c = (Integer.parseInt(BufferReader.readLine()))+1;
  
                      llenaarr();
                      llenamat();
                      minimo();
                      System.out.println("The minimum cutting is "+mat[0][c]+".");
                      }
              }
      }
  </code></pre>