[SWEA] 태혁이의 사랑은 타이밍

문제 보러가기

제한사항

3개의 정수의 범위는 D (11 ≤ D ≤ 14), H (0 ≤ H ≤ 23), M (0 ≤ M ≤ 59) 이다.

만약 소개팅 약속 시간 전에 차였다면 놀리기엔 너무 불쌍하므로 -1을 출력한다.

첫번째 생각

문제가 너무 슬펐따한다…

day * 24 * 60

hour * 60

month

를 모두 더하여 계산한다.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.Scanner;

public class Solution {
	    public static void main(String[] args) throws Exception {
	        Scanner sc = new Scanner(System.in);
	        int T = sc.nextInt();
	         
	        for(int tc = 1; tc <= T; tc++) {
	            int d = (sc.nextInt()-11) * 24 * 60;
	            int h = (sc.nextInt()-11) * 60;
	            int m = sc.nextInt()-11;
	             
	            System.out.println("#" + tc + " " + (((d+h+m) > -1) ? d+h+m : -1));
	        }
	    }
	}