import java.util.*;
import java.io.*;
public class 区间k大数查询 {
public static void main(String[] args){
Scanner in=new Scanner(new BufferedInputStream(System.in));
int n = in.nextInt();
int[] num = new int[n];
for (int i = 0; i < n; i++) {
num[i] = in.nextInt();
}
int m = in.nextInt();
int[][] arr = new int[m][3];
for (int i = 0; i < m; i++) {
arr[i][0] = in.nextInt();
arr[i][1] = in.nextInt();
arr[i][2] = in.nextInt();
}
for (int i = 0; i < m; i++) {
int[] temp = new int[arr[i][1] - arr[i][0] + 1];
temp = Arrays.copyOfRange(num, arr[i][0] - 1, arr[i][1]);
//copyOfRange将指定数组的指定范围复制到一个新数组
Arrays.sort(temp);
System.out.println(temp[arr[i][1] - arr[i][0] + 1 - arr[i][2]]);
}
}
}
时间: 2024-10-12 23:34:22