(1).백준 6249번 TV Reports는 긍정적인 내용만 보도하는 BBTV와 부정적인 내용만 보도하는 NTV가 있다.

BBTV는 최고기록을 갱신할 경우 해당 내용을 보도해야 하기 때문에 max보다 클 경우 result에 추가했고

NTV는 어제보다 떨어질 경우 얼마나 떨어졌는지를 알려주기 때문에 어제의 기록보다 낮은 경우

해당 내용과 비교해 얼마나 떨어졌는지를 출력하는 방식으로 해결했다.

const input = `8 140 180
120
200
150
150
180
170
250
220`.split('\n')

let [amount, yesterday, max] = input[0].split(' ').map(Number)
const result = []

for(let i = 1 ; i < input.length ; i++){
    const today = Number(input[i])
    if(today < yesterday){
        result.push(`NTV: Dollar dropped by ${yesterday-today} Oshloobs`)
    }
    else if(max < today){
        result.push(`BBTV: Dollar reached ${today} Oshloobs, A record!`)
        max = today
    }
    
    yesterday = today
}

console.log(result.join('\n'))

'회고' 카테고리의 다른 글

[수습일지] - 82(창립기념일)  (0) 2023.06.16
[수습일지] - 81  (0) 2023.06.15
[수습일지] - 79  (0) 2023.06.13
[수습일지] - 78  (0) 2023.06.12
[수습일지] - 77(주말)  (0) 2023.06.11

+ Recent posts