记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 2ms 204.0 KiB

代码

#include <stdio.h>
#include <stdlib.h>
#define N 10005
int a[N];

int cmp(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}

void swap(int* a, int* b)
{
	int t;
	t = *a;
	*a = *b;
	*b = t;
}

int main(void)
{
	int n, m;
	scanf("%d", &n);
	scanf("%d", &m);
	int i, j, k;
	for (i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (k = 0; k < m; k++)
	{
		for (i = n; i >= 1; i--)
		{
			for (j = n - 1; j >= 1; j--)
				if (a[j] < a[i])
				{
					swap(&a[i], &a[j]);
					qsort(a + j + 1, n - j, sizeof(int), cmp);
					i = j = 0;
				}
		}
	}
	for (i = 1; i <= n; i++)
		printf("%d ", a[i]);
}

信息

递交者
类型
自测
题目
P1005 hitwh 2019 新生赛 F Ramen and his faculty
语言
C
递交时间
2020-12-26 10:36:15
评测时间
2020-12-26 10:36:15
评测机
分数
0
总耗时
2ms
峰值内存
204.0 KiB