본문으로 바로가기

출제 링크 : https://www.acmicpc.net/problem/2884

 

2884번: 알람 시계

상근이는 매일 아침 알람을 듣고 일어난다. 알람을 듣고 바로 일어나면 다행이겠지만, 항상 조금만 더 자려는 마음 때문에 매일 학교를 지각하고 있다. 상근이는 모든 방법을 동원해보았지만,

www.acmicpc.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Solution
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] Time = Console.ReadLine().Split();

            int H = int.Parse(Time[0]);
            int M = int.Parse(Time[1]);

            if (H < 0 || H > 24 || M < 0 || M > 59) return;

            if(M<45)
            {
                H--;
                M += 15;

                if(H<0)
                {
                    H = 23;
                }
            }
            else
            {
                M -= 45;
            }

            Console.WriteLine($"{H} {M}");
        }
    }
}