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>
int data[100000];
int main()
{
int N, K;
//freopen("input.txt", "r", stdin);
scanf("%d %d ", &N, &K);
for (int i = 0; i < N; i++) {
scanf("%d ", &data[i]);
}
if (K >= N - 1) K = N - 1;
for (int i = 0; i < K; i++) {
int change = 0;
for (int j = 0; j < N - 1 - i; j++) {
if (data[j] > data[j + 1]) {
int temp;
temp = data[j];
data[j] = data[j + 1];
data[j + 1] = temp;
change = 1;
}
}
if (change == 0) break;
}
for (int i = 0; i < N; i++) printf("%d ", data[i]);
}
# | 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... |