记录详情

Wrong Answer


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

代码

#include<stdio.h>

void quick_sort(int s[], int l, int r)
{
    if(l < r)
    {
        int i = l, j = r, x = s[l];
        while(i < j)
        {
            while(i < j && s[j] >= x)
                j--;
            if(i < j)
                s[i++] = s[j];

            while(i < j && s[i] < x)
                i++;
            if(i < j)
                s[j--] = s[i];
        }
        s[i] = x;
        quick_sort(s, l, i - 1);
        quick_sort(s, i + 1, r);
    }
}

    int main(void)
{
    int n;
    long m, sum = 0;
    _Bool flag = 1;
    scanf("%d%ld", &n, &m);

    int t[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &t[i]);
    quick_sort(t, 0, n);

    for (int i = 0; i < n; i++)
    {
        sum = sum +((n - i) * t[i]);
        if(sum > m)
        {
            flag = 0;
            break;
        }
    }

    if(flag == 0)
        printf("No");
    else
        printf("Yes");

    return 0;
}

信息

递交者
类型
递交
题目
P1007 hitwh 2019 新生赛 H Songer and his army
语言
C
递交时间
2020-12-23 14:09:06
评测时间
2020-12-23 14:09:06
评测机
分数
30
总耗时
7ms
峰值内存
224.0 KiB