//区间K大数查询 #include<stdio.h> int main(){ int n,m,l,r,k,index = 0; scanf("%d",&n); int a[n]; for(int i=1;i<=n;i++) scanf("%d",&a[i]); scanf("%d",&m); while(m--){ int b[n]; scanf("%d%d%d",&l,&r,&k); for(int i=l;i<=r;i++) b[i] = a[i]; for(int i=1;i<=r-l;i++){ for(int j=l;j<=r-i;j++){ if(b[j] < b[j+1]){ int t; t = b[j];b[j] = b[j+1];b[j+1] = t; } } } printf("%d",b[l+k-1]); } return 0; }
原文地址:https://www.cnblogs.com/Hqx-curiosity/p/12252821.html
时间: 2024-10-23 05:38:05