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 1602. Elevator

WA#3
Posted by † SiriuS † [TWYT Union] 13 Mar 2014 15:47
Give some tests.
Re: WA#3
Posted by Landsknecht 23 May 2016 13:11
UP! Can someone explain why it happened?

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Lift {
    public static final float LIFT_DELAY = 15;
    public static final float PETYA_DELAY = 5;

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(reader.readLine());

        float petyaFloor = Float.parseFloat(st.nextToken());
        float liftFloor = Float.parseFloat(st.nextToken());

        float petyaSpeed = Float.parseFloat(st.nextToken());
        float liftSpeed = Float.parseFloat(st.nextToken());

        float timeByFootToTheFirstFloor = ((petyaFloor - 1) * petyaSpeed); //время, если идти до 1го этажа пешком
        float firstLiftDescentTime = ((liftFloor - 1) * liftSpeed) + LIFT_DELAY; //время, затраченное лифтом при спуске и простое на 1м этаже

        Float numOfFloorToGoByFoot = firstLiftDescentTime / petyaSpeed; //количество этажей, которые может успеть пройти Петя за время спуска лифта

        int numOfFloors = numOfFloorToGoByFoot.intValue(); //см. предыдущее

        Float numOfSeekingFloor = petyaFloor - numOfFloors; //искомый этаж

        float timeLiftWithPetya = (((numOfSearchingFloor - 1) * liftSpeed) * 2) + firstLiftDescentTime + PETYA_DELAY; //время на спуск, подъём к Пете на новый этаж и спуск с ним до 1го этажа

        if (timeByFootToTheFirstFloor < timeLiftWithPetya) {
            System.out.println("1");
        } else if (timeByFootToTheFirstFloor == timeLiftWithPetya) {
            String s = numOfSearchingFloor.longValue() + "";
            System.out.println(s);
        } else {
            String s = numOfSearchingFloor.longValue() + "";
            System.out.println(s);
        }
    }
}
Re: WA#3
Posted by Oleg Baskakov 23 May 2016 13:38
50 49 0.99 0.28
Answer 21, yours 22.
Re: WA#3
Posted by Landsknecht 23 May 2016 14:06
I've rounded up this float, now I get the same answer as you, but it still gives me WA#3 :( Could you please give me one more hint?


Edited by author 23.05.2016 14:07