 # https://www.codechef.com/LP1TO204/problems/SIGNFLIP

https://www.codechef.com/LP1TO204/problems/SIGNFLIP

above is the link of Ques that i’m trying to solve by QuickSor. Why its showing time limit exceed. Please help i am trying by best to solve this from 1 day.
#include <stdio.h>
void swap(int *a, int *b)
{
int t = *a;
*a = *b;
*b = t;
}
int partition(int arr[], int low, int high)
{
int pivot = arr[high]; // pivot
int i = (low - 1); // Index of smaller element and indicates the right position of pivot found so far

``````for (int j = low; j <= high - 1; j++)
{
// If current element is smaller than the pivot
if (arr[j] < pivot)
{
i++; // increment index of smaller element
swap(&arr[i], &arr[j]);
}
}
swap(&arr[i + 1], &arr[high]);
return (i + 1);
``````

}
void quickSort(int arr[], int low, int high)
{
if (low < high)
{
/* pi is partitioning index, arr[p] is now
at right place */
int pi = partition(arr, low, high);

``````    // Separately sort elements before
// partition and after partition
quickSort(arr, low, pi - 1);
quickSort(arr, pi + 1, high);
}
``````

}

int main()
{
int t;
scanf("%d", &t);
while (t–)
{
int count, k, total = 0, p = 0;
scanf("%d%d", &count, &k);
int arr[count];
for (int j = 0; j < count; j++)
{
int i;
scanf("%d", &i);
if (i > 0)
{
total = total + i;
}
else
{
arr[p] = i;
p++;
}
}
quickSort(arr, 0, p - 1);
if (p > k)
{
p = k;
}
for (int j = 0; j < p; j++)
{
arr[j] = arr[j] * -1;
total = total + arr[j];
}
printf("%d\n", total);
}
}

@ashish_777666 You can ask this to the doubt solver here - CodeChef. They should be able to help you.