ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1025. Democracy in Danger

Runtime error java
Posted by Schwarz 29 Jun 2016 16:27
Прекрасно работает в IDE, а на сервере ошибка. Объясните в чем дело
import java.util.LinkedList;
import java.util.Scanner;
import static java.util.Collections.sort;

public class Bird {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        sumGol(minKol(i), toConteiner(i));
    }
    public static LinkedList<Integer> toConteiner(int i) {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split(" ");
        LinkedList<Integer> in = new LinkedList<>();
        for (int j = 0; j < str.length; j++) in.add(Integer.parseInt(str[j]));
        return in;
    }
    public static int minKol(int i) {
        if (i % 2 != 0) i = i / 2 + 1;
        else i = i / 2;
        return i;
    }
    public static void sumGol(int i, LinkedList<Integer> l) {
        sort(l);
        int sum = 0;
        for (int j = 0; j < i; j++) {
            sum = sum + minKol(l.get(j));
        }
        System.out.print(sum);
    }
}
Re: Runtime error java
Posted by Sergey 21 May 2020 02:02
На этот вопрос есть где-нибудь ответ?
У меня другой код, та же ошибка. (