Namely, given an array arr[1..n] of different integer numbers,
your program must answer a series of questions Q(i, j, k) in the form:
what would be the k-th number in arr[i..j] segment, if this segment was sorted?#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int arr[] = { 13, 9, 3, 8, 11, 42, 5, 6, 4, 19, 77, 1, 7 };
vector<int> a(arr, arr + sizeof(arr) / sizeof(arr[0]));
return 0;
}
Any ideas to find it in the fastest way?