Оцени лаконичность=)

 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
#include <cstdio>
#include <map>
using namespace std;
int main (void)
{
map<int, int> mymap;
map<int, int> rmap;
map<int, int>::iterator it;
map<int, int>::iterator it2;
int n, m, x, i, j, l, k;
scanf ("%d%d", &n, &m);
i=1;
while (i<=n)
{
scanf ("%d", &x);
mymap[i]=x;
i++;
}
while (m--)
{
scanf ("%d%d%d", &i, &j, &k);
l=0;
for ( it=mymap.find(i) ; it != mymap.find(j); it++, l++ )
rmap[(*it).second]=l;
rmap[(*it).second]=l;
for (l=0, it=rmap.begin(); l<k-1; l++) it++;
printf ("%d\n", (*it).first);
rmap.clear();
}
return 0;
}