728x90
https://school.programmers.co.kr/learn/courses/30/lessons/150369
class Solution {
public long solution(int cap, int n, int[] deliveries, int[] pickups) {
long answer = 0;
int d=0;
int p =0;
for(int i=n-1;i>=0;i--){
d -= deliveries[i];
p -= pickups[i];
while(d<0 || p<0 ){
d+=cap;
p+=cap;
answer += (i+1)*2;
}
}
return answer;
}
}
어렵짜나!!! 이런 거 생각 못하자나 나는!!!!
728x90
'🐣 알고리즘 삐약 > ✏️ 냅다 덤벼보는 문제풀이' 카테고리의 다른 글
[프로그래머스] 폰켓몬 | 해시 | lv.1 | JAVA (0) | 2024.10.31 |
---|---|
[프로그래머스] LV1. 가장 많이 받은 선뭉 | JAVA (0) | 2024.08.16 |
[프로그래머스] LV.1 개인정보 수집 유효기간 | JAVA (0) | 2024.08.15 |
[codeforces] Ebony and Ivory | Cpp (0) | 2022.05.24 |
[C++] UVa 10718 : Bit Mask (0) | 2022.04.21 |