728x90
https://www.acmicpc.net/problem/2075
package BaekJoon.TwoPointer;
import java.io.*;
import java.util.*;
public class N번째큰수 {
static int n;
static int[][]arr;
static StringTokenizer st;
/*Sliding Window*/
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
st = new StringTokenizer(br.readLine());
n = Integer.parseInt(st.nextToken());
PriorityQueue<Integer>pq = new PriorityQueue<Integer>();
StringTokenizer st;
String line = br.readLine();
st = new StringTokenizer(line);
for(int i=0; i<n; i++) {
pq.offer(Integer.parseInt(st.nextToken())); //앞에 줄을 모두 넣어준다
}
for(int i=1; i<n; i++) {
st = new StringTokenizer(br.readLine());
for(int j=0; j<n; j++) {
int num = Integer.parseInt(st.nextToken());
if(pq.peek()<num) { //최소값이 num보다 작을때 num을 넣어준다
pq.poll(); //빼주고
pq.offer(num); //넣어준다
}
}
}
System.out.println(pq.poll());
}
}
'백준 > 슬라이딩윈도우' 카테고리의 다른 글
회전초밥 - Java (0) | 2021.10.06 |
---|---|
DNA비밀번호 (1) | 2021.10.02 |
가장긴짝수연속합부분수열 (0) | 2021.10.02 |
게으른 백곰 - 10025번(Java) (0) | 2021.09.16 |
꿀아르바이트 - 12847번(Java) (0) | 2021.09.16 |