#include #include #include int count=0; int bubblesort(int x[ ], int n) { int i, j, temp,c=0; for (i = 0; i < n - 1; i++) { for (j = n - 1; j > i; j--) { if (x[j - 1] > x[j]) { temp = x[j]; x[j] = x[j - 1]; x[j - 1]= temp; c++; } } } printf("%d",c); return c; } int selectsort(int num[ ], int n){ int i, j, k, min, temp,c=0; for (i = 0; i < n - 1; i++) { min = num[i]; k = i; for (j = i + 1; j < n; j++) { if (num[j] < min) { min = num[j]; k = j; } } temp = num[i]; num[i] = num[k]; num[k] = temp; c++; } printf("%d",c); return c; } void Swap(int x[ ], int i, int j) { int temp; temp = x[i]; x[i] = x[j]; x[j] = temp; } void quicksort(int x[ ], int left, int right) { int i, j; int pivot; i = left; j = right; pivot = x[(left + right) / 2]; while (1) { while (x[i] < pivot) i++; while (pivot < x[j]) j--; if (i >= j) break; Swap(x, i, j); count++; i++; j--; } if (left < i - 1) quicksort(x, left, i - 1); if (j + 1 < right) quicksort(x, j + 1, right); } int main(){ int i,N,K,ary[200000],cp[200000],ans,flag=0; scanf("%d",&N); scanf("%d",&K); //printf("%d",N); //printf("%d",K); for(i=0;i