|
|
back to boardjava ac 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 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 |
|
|