백준 #22015번 金平糖 (Konpeito)

jhj·2024년 2월 14일

백준 JAVA

목록 보기
286/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int count = 0;
		int max = Math.max(a, b);
		max = Math.max(max, c);
		
		if(max > a) {
			count += max - a;
		}
		
		if(max > b) {
			count += max - b;
		}
		
		if(max > c) {
			count += max - c;
		}
		
		System.out.println(count);
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글