Skip to content

Commit 222b326

Browse files
authored
Merge pull request #1048 from AlgorithmWithGod/lkhyun
[20251005] PGM / Lv2 / 택배 배달과 수거하기 / 이강현
2 parents ebfd495 + 7921e93 commit 222b326

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
```java
2+
3+
class Solution {
4+
public long solution(int cap, int n, int[] deliveries, int[] pickups) {
5+
long answer = 0;
6+
7+
int deliveryLoad = 0;
8+
int pickupLoad = 0;
9+
10+
for (int i = n - 1; i >= 0; i--) {
11+
deliveryLoad += deliveries[i];
12+
pickupLoad += pickups[i];
13+
14+
while (deliveryLoad > 0 || pickupLoad > 0) {
15+
deliveryLoad -= cap;
16+
pickupLoad -= cap;
17+
18+
answer += (i + 1) * 2;
19+
}
20+
}
21+
22+
return answer;
23+
}
24+
}
25+
```

0 commit comments

Comments
 (0)