Yet Again a Subarray Problem SUBPRNJL Help!

I have been getting TLE in one test-case. I don’t how to optimize it more. Please help me.

My solution link:

your link gives “access denied” error

I don’t know why it’s happening. Can you help me with it? Or should I just copy-paste the code here.

This question is a part of ongoing DSA. Solutions are not visible yet.

So can I copy-paste the code here?

Yeah, I think you can do


using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<pair<int, int> , null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>

int main() {
	// ios::sync_with_stdio(false);
	// cin.tie(NULL);
	int t;
	scanf("%d", &t);
	while(t--) {
		int n, k;
		scanf("%d %d", &n, &k);
		vector <int> v(n);
		for (int i=0; i<n; i++) {
			scanf("%d", &v[i]);
		long long int count =0; 
		for (int i=0; i<n; i++) {
			vector <int> count_indices (2001, 0);
			ordered_set s;
			for (int j=i; j<n; j++) {
				int size = j - i + 1;
				double temp = ceil(double (k) /size);
				temp = ceil(k/temp);
				s.insert({v[j], j});
				auto it = s.find_by_order(temp-1);
				int f = count_indices[it->first];
				if (count_indices[f]) {
		printf("%lld\n", count);
	return 0;