function solution(fees, records) {
var answer = [];
let carArray=[]
let basic=fees[0];
let basicFee=fees[1];
let add=fees[2];
let addFee=fees[3];
for (let i=0;i<records.length;i++){
let cut=records[i].split(' ');
carArray.push(cut[1]);
}
carArray=carArray.filter((a,b)=>carArray.indexOf(a)===b)
carArray.sort();
for (let i=0;i<carArray.length;i++){
let listArray=[];
for(let j=0;j<records.length;j++){
if (records[j].split(' ')[1]===carArray[i]){
console.log(records[j].split(' ')[1], records[j])
listArray.push(records[j].split(' ')[0])
}
}
let totalFee=0;
let useTime=0;
for (let i=0;i<Math.ceil(listArray.length/2);i++){
let carIn=listArray[2*i]
let carOut=listArray[2*i+1]
let carInTime=(+carIn.split(':')[0])*60+(+carIn.split(':')[1]);
let carOutTime=0;
if (carOut!==undefined){
carOutTime=(+carOut.split(':')[0])*60+(+carOut.split(':')[1]);
}else{
carOutTime=23*60+59
}
useTime+=(carOutTime-carInTime)
}
if (useTime<basic){
totalFee+=basicFee;
}else{
totalFee+=basicFee;
useTime-=basic;
totalFee+=Math.ceil(useTime/add)*addFee
}
answer.push(totalFee)
}
return answer;
}
문제를 정확하게 읽자...