백준 #16204번 카드 뽑기

jhj·2024년 2월 12일

백준 JAVA

목록 보기
242/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int o = sc.nextInt();
		int k = sc.nextInt();
		int x = n - o;
		int total = 0;
		
		if(o >= k) {
			total += k;
		}else {
			total += o;
		}
		
		if(x >= n - k) {
			total += n - k;
		}else {
			total += x;
		}
		
		System.out.println(total);
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글