-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2104.cpp
More file actions
38 lines (36 loc) · 873 Bytes
/
2104.cpp
File metadata and controls
38 lines (36 loc) · 873 Bytes
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
32
33
34
35
36
37
38
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
typedef struct _number{
int num;
int pos;
}Number;
int comp(const void* num1,const void *num2){
return ((Number*)num1)->num-((Number*)num2)->num;
}
int main() { //poj2104
int n,m;
scanf("%d %d",&n,&m);
Number *numbers=new Number[n];
for(int i=0;i<n;i++){
scanf("%d",&numbers[i].num);
numbers[i].pos=i+1;
}
qsort(numbers,n,sizeof(Number),comp);
for(int i=0;i<m;i++){
//process case
int start,end,k;
scanf("%d %d %d",&start,&end,&k);
//TODO:
for(int j=0,cur=0;j<n;j++){
if(numbers[j].pos>=start&&numbers[j].pos<=end) cur++;
if(cur==k){
printf("%d\n",numbers[j].num);
break;
}
}
}
delete[] numbers;
return 0;
}