Biggest of Five

java

#1

Hi,
I have a TLE problem with problem Biggest of Five on Java. Can anybody help me to improve my solution? Here is my code: [https://pastebin.com/3PZtQs7z](http://Biggest of Five)


#2

Hello,

Your solution is fine, I’ve increased the time limit for java submissions as they traditionally require > 0.2 sec. Feel free to try your solution again.

Cheers,
Edward.


#3

Hello, Edward,
Yes, now is OK. Because I’ve tried too many versions of my code and always was passed with TLE. But now is OK. Thank you!

BS,
Atila


#4

Здравейте,
Получавам резултат 7/14. Къде бъркам? Ето го и кода:

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    double first = Double.parseDouble(input.nextLine());
    double second = Double.parseDouble(input.nextLine());
    double third = Double.parseDouble(input.nextLine());
    double fourth = Double.parseDouble(input.nextLine());
    double fifth = Double.parseDouble(input.nextLine());

    double maxvalue = -200000000;
    if (first > maxvalue) {
        maxvalue = first;
    }
    if (second > maxvalue) {
        maxvalue = second;
    }
    if (third > maxvalue) {
        maxvalue = third;
    }

    if (fourth > maxvalue) {
        maxvalue = fourth;
    }
    if (fifth > maxvalue) {
        maxvalue = fifth;
    }
    System.out.printf("%.0f", maxvalue);


}

}


#5

Здравей
тук:

1.5 го принтираш като 2, 1.4 като 1 и тн :slight_smile:


#6

Здравей,

Пробема е че трябва да сложиш една проверка за принтирането.

Тук може да погледнеш модификацията, която ти е необходима:
https://pastebin.com/sGfH7FWy


#7

Благодаря, Денски и Стоян :slight_smile: