pages:
  • 1
MehrdadSComputer SAYS

hi, this is my code, it's fine when running on ide, but after submit,it shows run time error, what's problem?

import java.util.Scanner;
import java.util.Set;

public class Main {

private static Integer count, sum, average;
private static String line, bully, victim;
private static Scanner input = new Scanner(System.in);
private static String[] temp = new String[4];
private static Integer[] a = new Integer[9];
private static Integer[] b = new Integer[9];
private static Integer[] c = new Integer[9];
private static String[] name = new String[9];
private static Integer[] sumAlone = new Integer[9];

public static void main(String[] args) {

    count = Integer.parseInt(input.nextLine());
    while (count != (-1)) {
        average = sum = 0;

        for (int i = 0; i < count; i++) {
            line = input.nextLine();
            temp = line.split(" ");
            a[i] = Integer.parseInt(temp[0]);
            b[i] = Integer.parseInt(temp[1]);
            c[i] = Integer.parseInt(temp[2]);
            name[i] = temp[3];
            sumAlone[i] = a[i] * b[i] * c[i];
            sum = sum + sumAlone[i];

        }
        average = sum / count;

        for (int j = 0; j < count; j++) {
            if (sumAlone[j] > average) {
                bully = name[j];
            } else if (sumAlone[j] < average) {
                victim = name[j];
            }
        }
        System.out.print(bully + " took clay from " + victim + ".\n");
        count = Integer.parseInt(input.nextLine());
    }
}

}

AMiR SAYS

It was a problem with judging system!

Your run has been rejudged and it is accepted! :)

Sorry for that issue!