记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 1ms 220.0 KiB
#2 Accepted 1ms 216.0 KiB
#3 Accepted 1ms 128.0 KiB
#4 Accepted 0ms 220.0 KiB
#5 Accepted 0ms 128.0 KiB
#6 Accepted 0ms 216.0 KiB
#7 Accepted 0ms 128.0 KiB
#8 Accepted 0ms 220.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;
    unsigned long long 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++)
        printf("%d ", t[i]);
    printf("\n");*/
    for (int i = 0; i < n; i++)
    {
        sum = sum +((n - i) * t[i]);
        if(sum >= m)
        {
            flag = 0;
            break;
        }
    }

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

    return 0;
}

信息

递交者
类型
递交
题目
P1007 hitwh 2019 新生赛 H Songer and his army
语言
C
递交时间
2020-12-23 15:23:03
评测时间
2020-12-23 15:23:03
评测机
分数
100
总耗时
8ms
峰值内存
220.0 KiB