Runtime Error Message Java

703 views Asked by At

While doing USACO problem, I got the following runtime error message however I do not know the problem with my code that would fix the error message. I have already tested it and wrote it to my own system and it prints out the output file correctly however the error message still exists. The error message is as follows:

Runtime error or memory limit exceeded on sample input case -- details below Your output file bteams.out: [File missing!]

The correct answer: 1

The following appeared on standard error: [File missing!]

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;


public class bteams {

    public static void main(String[] args) throws IOException {
        File file = new File("bteams.in");
        Scanner scan = new Scanner(file);
        PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("bteams.out")));
        int input [] = new int [12];
        for(int i = 0; i < 12; i++)
        {
            input[i] = scan.nextInt();
        }
        scan.close();
        Arrays.sort(input);

        int sums [] = new int[4];

        sums[0] = input[11] + input[0] + input[6];
        sums[1] = input[10] + input[1] + input[5];
        sums[2] = input[9] + input[4] + input[3];
        sums[3] = input[8] + input[7] + input[2];

        int largest = sums[0];
        int smallest = sums[0];
        for(int j = 1; j < 3; j++)
        {
            if(sums[j]> sums[j-1])
            {
                largest = sums[j];
            }
            else if(sums[j] < sums[j-1])
            {
                smallest = sums[j];
            }
        }

        //System.out.println(largest-smallest);
        pw.println(largest-smallest);
        pw.flush();
        pw.close();


    }


}
0

There are 0 answers