티스토리 뷰
import java.util.Queue;
import java.util.LinkedList;
import java.util.List;
import java.util.ArrayList;
class Solution {
public int[] solution(int[] progresses, int[] speeds) {
Queue<Double> queue = new LinkedList<>();
for(int i = 0; i < progresses.length; i++) {
int tmp = (100 - progresses[i]) / speeds[i];
if(((100 - progresses[i]) % speeds[i]) == 0) {
queue.add((double) tmp);
} else {
queue.add(tmp + 0.1);
}
}
List<Integer> list = new ArrayList<>();
int deploy = 0;
while(!queue.isEmpty()) {
double front = queue.poll();
deploy++; // 처음 무조건 하나는 배포
while(queue.size() > 0 && front >= queue.peek()) {
queue.poll();
deploy++;
}
list.add(deploy);
deploy = 0;
}
int[] answer = new int[list.size()];
for(int i = 0; i < list.size(); i++) {
answer[i] = list.get(i);
}
return answer;
}
}
// 100 - 90 = 10 / 10 = 1
// 100 - 90 = 10 / 9 = 1.111111111111111...
// 100 - 93 = 7 / 1 = 7;
// 100 - 30 = 70 / 30 = 2.3333...
// 100 - 55 = 45 / 5 = 9;
// 100 - 95 = 5
// 100 - 90 = 10
// 100 - 99 = 1
// 100 - 99 = 1
// 100 - 80 = 20
// 100 - 99 = 1
'흥미 > 코딩테스트' 카테고리의 다른 글
#32😊 카펫(완전탐색) (0) | 2024.03.13 |
---|---|
#31😂 모의고사(완전탐색) (0) | 2024.03.12 |
#30😊 폰켓몬 (0) | 2024.03.07 |
#29🤔 올바른 괄호 (0) | 2024.03.04 |
#28😊 같은 숫자는 싫어 with Stack (0) | 2024.02.26 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- node.js
- 메모리
- 알고리즘
- MySQL
- 자료구조
- API
- db
- Java8
- 빅데이터
- Spring Boot
- Advanced Stream
- git
- SpringBoot
- nosql
- OS
- DART
- java
- 코테
- 운영체제
- spring
- jpa
- Phaser
- SQL
- 코딩테스트
- MongoDB
- 프로세스
- Stream
- 빅데이터 분석기사
- 프로그래머스
- Phaser3
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함