Yeji's Tech Notes
article thumbnail
반응형

📝 문제

 

풀이

import java.io.*;
import java.util.Arrays;

class Main {

	private static final int MINUTES = 60;
    private static final int HOURS = 24;

    public static void main(String[] args) {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            System.out.print(solution(reader));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static String solution(BufferedReader br) throws IOException {
        int n = Integer.parseInt(br.readLine());
        int[] time = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        for (int i = 0; i < n; i++) {
            time = makeFunctionTime(time, Integer.parseInt(br.readLine()));
        }

        return time[0] + " " + time[1];
    }

    private static int[] makeFunctionTime(int[] time, int processingTime) {
        int currentHour = time[0];
        int currentMinutes = time[1];

        int plusHour = (currentMinutes + processingTime) / MINUTES;
        int modMinutes = (currentMinutes + processingTime) % MINUTES;

        return new int[]{(currentHour + plusHour) % HOURS, modMinutes};
    }
}

 

🧐 느낀점

2일차 밖에 안되서 그런지 문제가 쉽다는 느낌이 많이 들어요 시간재고 풀고있는데 아직 30분을 안넘기네요

하지만 시간이 지날수록 문제가 어려워질 것이라 예상되기에 지금을 즐겨보는 걸로,,,ㅎㅎ

 

 

반응형
profile

Yeji's Tech Notes

@Jop

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!