function solution(fees, records){
let minTime=fees[0];
let minPrice=fees[1];
let unitTime=fees[2];
let unitPrice=fees[3];
let cars=[];
let answer=[];
for (let i=0;i<records.length;i++){
cars.push(records[i].split(' ')[1]);
}
let carsArray=new Set(cars);
cars=[...carsArray].sort()
for (let i=0;i<cars.length;i++){
let carRecordArray=[];
for (let j=0;j<records.length;j++){
if (records[j].split(' ')[1]===cars[i]){
carRecordArray.push(records[j].split(' '))
}
}
// 각 차의 요금 구하기
let usedTime=0;
// console.log('car', carRecordArray, carRecordArray.length)
for (let j=0;j<carRecordArray.length;j++){
// console.log('car', carRecordArray[j])
if (carRecordArray[j][2]==='IN'){
// 출차는
// 출차 기록이 없는 경우
if (j===carRecordArray.length-1){
usedTime+=
23*60+59-parseInt(carRecordArray[j][0].split(':')[0])*60
-carRecordArray[j][0].split(':')[1];
console.log('???')
}
// 그건 아닐 경우
else{
// 출차 시간
if(carRecordArray[j+1]){
// console.log('car', carRecordArray[j+1])
let out=carRecordArray[j+1];
// console.log('out', out)
// 입차 시간 해서 계산
usedTime+=
(parseInt(out[0].split(':')[0])*60+parseInt(out[0].split(':')[1])
-(parseInt(carRecordArray[j][0].split(':')[0]*60)+parseInt(carRecordArray[j][0].split(':')[1])));
}
}
j+=1;
}
}
// 요금 구해서 어레이에 넣기
let feeAnswer=0;
if (usedTime<=minTime){
feeAnswer=minPrice;
}else{
feeAnswer+=minPrice;
//남은 시간
let leftTime=usedTime-minTime;
feeAnswer+=Math.ceil(leftTime/unitTime)*unitPrice;
}
answer.push(feeAnswer);
}
return answer;
}