본문 바로가기
백준/출제한 문제들

[백준] 28454번 : Gift Expire Date

by lms0806 2023. 8. 21.
728x90
반응형

https://www.acmicpc.net/problem/28454

 

28454번: Gift Expire Date

임스는 여러 사람에게 기프티콘을 받았다. 현재 사용할 수 있는 기프티콘이 몇 개인지 궁금했던 임스는 지금까지 받은 기프티콘을 확인하고자 한다. 임스가 현재 사용할 수 있는 기프티콘의 총

www.acmicpc.net

 

제가 좋아하지 않는 분류 중 하나인 날짜 관련해서 문제를 출제해봤습니다.

 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] s = br.readLine().split("-");
		int y = Integer.parseInt(s[0]), m = Integer.parseInt(s[1]), d = Integer.parseInt(s[2]);
		
		int n = Integer.parseInt(br.readLine());
		
        int answer = 0;
		for(int i = 0; i < n; i++) {
			String[] str = br.readLine().split("-");
            int gifty = Integer.parseInt(str[0]), giftm = Integer.parseInt(str[1]), giftd = Integer.parseInt(str[2]);
            
            if(gifty > y) {
				answer++;
			}
			else if(gifty == y) {
				if(giftm > m) {
					answer++;
				}	
				else if(giftm == m && giftd >= d) {
					answer++;
				}
			}
		}
		
		System.out.print(answer);
	}
}
728x90
반응형

댓글