This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define MAX 100001
int arr[MAX];
int brr[MAX];
int check[MAX];
int main()
{
int n, k;
scanf("%d%d", &n, &k);
int i, j;
for (i = 1; i <= n; i++)
{
scanf("%d", &arr[i]);
brr[i] = arr[i];
}
int temp;
int e = n;
for (i = 1; i <= k; i++)
{
for (j = 1; j < e; j++)
{
if (arr[j]>arr[j + 1]&&check[j]==0)
{
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
for (i = 1; i < e; i++)
{
if (arr[i] == brr[i])
check[i] = 1;
brr[i] = arr[i];
}
e -= 1;
}
for (i = 1; i <= n; i++)
printf("%d ", arr[i]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |