记录详情

Wrong Answer


  
# 状态 耗时 内存占用
#1 Wrong Answer 1ms 204.0 KiB
#2 Wrong Answer 1ms 128.0 KiB
#3 Wrong Answer 1ms 220.0 KiB
#4 Wrong Answer 0ms 128.0 KiB
#5 Wrong Answer 0ms 216.0 KiB
#6 Wrong Answer 0ms 128.0 KiB
#7 Wrong Answer 0ms 220.0 KiB
#8 Wrong Answer 0ms 128.0 KiB
#9 Wrong Answer 0ms 208.0 KiB

代码

#include <stdio.h>
#include <stdlib.h>
#define N 1000

int cmp(const void* a,const void* b)
{
	return *(int*)a - *(int*)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:30:52
评测时间
2020-12-17 15:30:52
评测机
分数
0
总耗时
8ms
峰值内存
220.0 KiB