Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lkhyun/202510/05 PGM Lv2 택배 배달과 수거하기.md
Original file line number Diff line number Diff line change
@@ -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;
}
}
```