From 1b855338e1c0d192431a0ff8128b4155f3c36225 Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Fri, 12 Dec 2025 23:45:42 +0900 Subject: [PATCH] =?UTF-8?q?[20251212]=20PGM=20/=20LV2=20/=20=EC=A3=BC?= =?UTF-8?q?=EC=B0=A8=20=EC=9A=94=EA=B8=88=20=EA=B3=84=EC=82=B0=20/=20?= =?UTF-8?q?=EC=9D=B4=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\352\270\210 \352\263\204\354\202\260.md" | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 "LiiNi-coder/202512/12 PGM \354\243\274\354\260\250 \354\232\224\352\270\210 \352\263\204\354\202\260.md" diff --git "a/LiiNi-coder/202512/12 PGM \354\243\274\354\260\250 \354\232\224\352\270\210 \352\263\204\354\202\260.md" "b/LiiNi-coder/202512/12 PGM \354\243\274\354\260\250 \354\232\224\352\270\210 \352\263\204\354\202\260.md" new file mode 100644 index 00000000..f3d3d7c9 --- /dev/null +++ "b/LiiNi-coder/202512/12 PGM \354\243\274\354\260\250 \354\232\224\352\270\210 \352\263\204\354\202\260.md" @@ -0,0 +1,62 @@ +```java +import java.util.*; +import java.io.*; + +class Solution { + public int[] solution(int[] fees, String[] records) { + Map totalTime = new TreeMap<>(); + Map inTime = new HashMap<>(); + + for(String record : records){ + String[] parts = record.split(" "); + int hh = Integer.parseInt(parts[0].substring(0, 2)); + int mm = Integer.parseInt(parts[0].substring(3, 5)); + int time = hh * 60 + mm; + + String car = parts[1]; + String type = parts[2]; + if(type.equals("IN")){ + inTime.put(car, time); + } else { + int start = inTime.remove(car); + int duration = time - start; + + totalTime.put(car, totalTime.getOrDefault(car, 0) + duration); + } + } + for(String car : inTime.keySet()){ + int start = inTime.get(car); + int end = 23 * 60 + 59; + int duration = end - start; + totalTime.put(car, totalTime.getOrDefault(car, 0) + duration); + } + + + List answerList = new ArrayList<>(); + int basicTime = fees[0]; + int basicFee = fees[1]; + int unitTime = fees[2]; + int unitFee = fees[3]; + + for(int time : totalTime.values()){ + if(time <= basicTime){ + answerList.add(basicFee); + } else { + int extra = time - basicTime; + int count = extra / unitTime; + if(extra%unitTime != 0){ + count++; + } + answerList.add(basicFee + count * unitFee); + } + } + int[] answer = new int[answerList.size()]; + for(int i = 0; i < answerList.size(); i++){ + answer[i] = answerList.get(i); + } + + return answer; + } +} + +```