From 7921e9359092a0f07b0f9cf9dd39423f5c896e9f Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Sun, 5 Oct 2025 22:20:42 +0900 Subject: [PATCH] =?UTF-8?q?[20251005]=20PGM=20/=20Lv2=20/=20=ED=83=9D?= =?UTF-8?q?=EB=B0=B0=20=EB=B0=B0=EB=8B=AC=EA=B3=BC=20=EC=88=98=EA=B1=B0?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20/=20=EC=9D=B4=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...30\352\261\260\355\225\230\352\270\260.md" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "lkhyun/202510/05 PGM Lv2 \355\203\235\353\260\260 \353\260\260\353\213\254\352\263\274 \354\210\230\352\261\260\355\225\230\352\270\260.md" diff --git "a/lkhyun/202510/05 PGM Lv2 \355\203\235\353\260\260 \353\260\260\353\213\254\352\263\274 \354\210\230\352\261\260\355\225\230\352\270\260.md" "b/lkhyun/202510/05 PGM Lv2 \355\203\235\353\260\260 \353\260\260\353\213\254\352\263\274 \354\210\230\352\261\260\355\225\230\352\270\260.md" new file mode 100644 index 00000000..9b245f02 --- /dev/null +++ "b/lkhyun/202510/05 PGM Lv2 \355\203\235\353\260\260 \353\260\260\353\213\254\352\263\274 \354\210\230\352\261\260\355\225\230\352\270\260.md" @@ -0,0 +1,25 @@ +```java + +class Solution { + public long solution(int cap, int n, int[] deliveries, int[] pickups) { + long answer = 0; + + int deliveryLoad = 0; + int pickupLoad = 0; + + for (int i = n - 1; i >= 0; i--) { + deliveryLoad += deliveries[i]; + pickupLoad += pickups[i]; + + while (deliveryLoad > 0 || pickupLoad > 0) { + deliveryLoad -= cap; + pickupLoad -= cap; + + answer += (i + 1) * 2; + } + } + + return answer; + } +} +```