준환이의 운동관리_3431

heyryu·2022년 5월 25일
0

SWEA

목록 보기
4/7

주어진 시간에 해당하는지 초과하는지 미달하는지 판단

SWEA Code

import java.util.Scanner;

class Solution
{
	public static void main(String args[]) throws Exception
	{
		Scanner sc = new Scanner(System.in);
		int T;
		T=sc.nextInt();

		for(int test_case = 1; test_case <= T; test_case++)
		{
			int l = sc.nextInt();	//최소시간
            int u = sc.nextInt();	//최대시간
            int x = sc.nextInt();	//내가 운동한 시간
            int result = 0;
           
            //필요한 양보다 더 많은 운동을 하고 있다면 -1을 출력
            if (x > u) {
                result = -1;
            } else if (x>=l && x <= u) {	//적당량 운동할 땐 0 출력
                result = 0;
            } else {	//추가로 몇 분을 더 운동해야 하는지 출력
            	result = l - x;
            }
            System.out.println("#"+test_case+" "+result);
		}
	}
}
profile
못하면 열심히 하는 게 당연하니까💪 [Frontend/서비스기획]

0개의 댓글