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
- 프로그래머스
- 문자열
- 알고리즘
- BOJ
- SQL
- 건강
- MySQL
- greedy
- math
- 코딩테스트
- 백준
- db
- 이분탐색
- oracle
- priorityqueue
- 문제풀이
- binary search
- SWEA
- 시뮬레이션
- DP
- dfs
- 러닝일지
- Java
- 문제해결
- 자바
- 투포인터
- 운동기록
- BFS
- 코테
- COS PRO
Archives
- Today
- Total
슈콩
[BOJ] 백준 2457 공주님의 정원 본문
[문제]
https://www.acmicpc.net/problem/2457
[소스 코드]
import java.io.*;
import java.util.*;
public class Main {
static class Flower{
int s,l;
Flower(int s,int l){
this.s = s;
this.l = l;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
Flower[] flower = new Flower[n];
for(int i=0;i<n;i++) {
st = new StringTokenizer(br.readLine());
int sm = Integer.parseInt(st.nextToken()) * 100;
int sd = Integer.parseInt(st.nextToken());
int lm = Integer.parseInt(st.nextToken()) * 100;
int ld = Integer.parseInt(st.nextToken());
flower[i] = new Flower(sm+sd,lm+ld);
}
int curr = 301;
int end = 301;
int result = 0;
while(curr<1201) {
for(int i=0;i<n;i++) {
if(flower[i].s<=curr && flower[i].l>end) {
end = flower[i].l;
}
}
if(end==curr) {
System.out.println(0);
return;
}
result++;
curr = end;
}
System.out.println(result);
}
}'Algorithms > Baekjoon' 카테고리의 다른 글
| [BOJ] 백준 7570 줄 세우기 (0) | 2025.09.04 |
|---|---|
| [BOJ] 백준 2457 공주님의 정원 (0) | 2025.09.04 |
| [BOJ] 백준 2170 선 긋기 (0) | 2025.08.28 |
| [BOJ] 백준 1744 수 묶기 (0) | 2025.08.28 |
| [BOJ] 백준 1700 멀티탭 스케줄링 (0) | 2025.08.28 |