For this Question: Given an array of n elements, where each element is at most k away from its position in the sorted array, you need to sort the array optimally.

Note: DO NOT use STL sort() function for this question.The first line contains two elements n and k separated by a space. The second line contains n elements of array.

Constraints:
1 <= n <= 100000
1 <= k <= n
1 <= arr(i) <= 1000000Print the sorted array.Sample Input:
7 3
6 5 2 3 8 10 9

Sample Output:
2 3 5 6 8 9 10, I have written this Solution Code: #include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int N = 1e3 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

priority_queue<int> p;

void solve(){
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= k-1; i++){
		int x;	cin >> x;
		p.push(-x);
	}
	for(int i = k; i <= n; i++){
		int x;	cin >> x;
		p.push(-x);
		cout << -p.top() << " ";
		p.pop();
	}
	while(!p.empty()){
		cout << -p.top() << " ";
		p.pop();
	}
}

void testcases(){
	int tt = 1; 
	//cin >> tt;
	while(tt--){
		solve();
	}
}

signed main() {
	IOS;
		clock_t start = clock();

	testcases();

	cerr << (double)(clock() - start)*1000/CLOCKS_PER_SEC << " ms" << endl;
	return 0;
}	, In this Programming Language: C++, Now tell me if this Code is compilable or not?