알고리즘/백준

백준 2965 캥거루 세마리

고구마와 감자 2022. 12. 9. 22:10

https://www.acmicpc.net/problem/2965

 

2965번: 캥거루 세마리

첫째 줄에 세 캥거루의 초기 위치 A, B, C가 주어진다. (0 < A < B < C < 100)

www.acmicpc.net

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        int maxVal = Math.max(c- b, b - a);
        System.out.println(maxVal - 1);
    }
}