알고리즘/백준
백준 25377 빵
고구마와 감자
2022. 12. 10. 10:32
https://www.acmicpc.net/problem/25377
25377번: 빵
KOI 빵은 프로그래밍을 공부하는 학생들에게 인기를 끌고 있다. 이 빵은 맛있을 뿐 아니라, 안에 프로그래밍에 큰 도움이 되는 여러 가지 힌트가 담겨 있어서 매우 인기가 높다. 이렇게 인기가 높
www.acmicpc.net
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
StringTokenizer st;
int minTime = Integer.MAX_VALUE;
boolean success = false;
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
if (b >= a) {
if (minTime > b) {
minTime = b;
success = true;
}
}
}
System.out.println(success ? minTime : -1);
}
}