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 1725. Sold Out!

java ac
Posted by pay_all_for 3 Aug 2014 07:02
import java.util.Scanner;

public class Sold_Out {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();

        if(n<3){
            System.out.println(0);
            return;
        }

        System.out.println(Math.max(k - 1, n - k) - 2);
    }
}
Re: java ac
Posted by illarionovam_onu 13 Jan 2016 01:12
your programm works only because of weak tests.
for example: 3 1
your answer is 0, but the correct one is 1.
1 _ _
1 _ 3
1 2 3 -> there is 1 person from both sides and the distance to number 2 is equal, so in the worst case the person will hit vasya.

Edited by author 13.01.2016 01:14

Edited by author 13.01.2016 01:14
Re: java ac
Posted by ... 21 Nov 2016 12:23
n is even