Wrong Answer
/in/foo.c: In function 'main': /in/foo.c:19:27: warning: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types] qsort(a, n, sizeof(int), cmp); ^~~ In file included from /in/foo.c:2:0: /usr/include/stdlib.h:725:13: note: expected '__compar_fn_t {aka int (*)(const void *, const void *)}' but argument is of type 'int (*)(int *, int *)' extern void qsort (void *__base, size_t __nmemb, size_t __size, ^~~~~
代码
#include <stdio.h>
#include <stdlib.h>
#define N 1000
int cmp(int* a, int* b)
{
return *a - *b;
}
int main(void)
{
int a[N] = { 0 };
int n;
int i;
long long int m;
scanf("%d%lld", &n, &m);
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
qsort(a, n, sizeof(int), cmp);
long long int sum = 0;
for (i = 0; i < n; i++)
sum += (-(long long int)i + n) * a[i];
printf("%lld", sum);
if (sum >= m)
printf("Yes");
else
printf("No");
}
信息
- 递交者
- 类型
- 递交
- 题目
- P1007 hitwh 2019 新生赛 H Songer and his army
- 语言
- C
- 递交时间
- 2020-12-17 15:21:10
- 评测时间
- 2020-12-17 15:21:11
- 评测机
- 分数
- 0
- 总耗时
- 8ms
- 峰值内存
- 228.0 KiB