Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
| 31 |
Tags
- Sort
- Java
- 개발자취업
- 99클럽 #코딩테스트준비 #개발자취업 #항해99 #til
- DB
- 항해99
- Algorithm
- JPA
- generic class
- dbms
- spring
- jsp
- python
- js
- 가상컴퓨팅
- sql
- 99클럽
- 코테
- 공개키 암호화
- mysql
- javascript
- 정렬
- LeetCode
- 자료구조
- 알고리즘
- 크루스칼
- 코딩테스트준비
- 코딩테스트
- til
- 위상정렬
Archives
- Today
- Total
PLOD
[백준] 캠프가는 영식(1590) 본문
🔗 문제 링크
https://www.acmicpc.net/problem/1590
✅ 코드
import java.io.*;
import java.util.*;
public class 백준_1590 {
static int[][] arr;
static PriorityQueue<Integer> busTime;
public static void main(String[] args) throws Exception {
int answer = -1;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int t = Integer.parseInt(st.nextToken());
arr = new int[n][3];
for(int i = 0; i < n ; i++){
st = new StringTokenizer(br.readLine());
arr[i][0] = Integer.parseInt(st.nextToken());
arr[i][1] = Integer.parseInt(st.nextToken());
arr[i][2] = Integer.parseInt(st.nextToken());
}
busTime = new PriorityQueue<>();
for (int i = 0; i < n; i++) {
for(int j = 0 ; j < arr[i][2]; j++){
busTime.add(arr[i][0] + arr[i][1] * j);
}
}
while (!busTime.isEmpty()) {
int x = busTime.poll();
if(x >= t){
answer = x - t;
break;
}
}
System.out.println(answer);
br.close();
}
}
💡 배운 점 & 느낀 점
1. PriorityQueue<Integer> → 우선순위 자료구조 (defaulr 최소 힙 구조)
2. Heap 자료구조에서 순서가 보장되려면 Poll로 자료를 뽑아내야 한다
'대외 활동 및 IT 지식 > 알고리즘 문제 풀이 정리' 카테고리의 다른 글
| [Leetcode] 349. Intersection of Two Arrays (0) | 2026.04.13 |
|---|---|
| [백준] 브실이의 입시전략(29723) (0) | 2026.04.10 |
| [백준] 단어 정렬(1181) (0) | 2026.04.10 |
| [Programmers] 조건에 맞는 개발자 찾기(MySQL) (0) | 2026.03.23 |
| [백준] 평행선(2358) (0) | 2026.03.23 |
Comments