科大讯飞-19届笔试

t = int(input())
res = []
for i in range(t):
    n , x = map(int,input().split())
    alist = list(map(int,input().split()))
    length = len(alist)
    count = 0
    alist = sorted(alist)
    while x*length >= sum(alist): #数组的和大于平均分乘人数
        alist[count] = 100#####
        count += 1
    res.append(count)
for i in res:
    print(i)

第二题


n = int(input())
# n=10
alist = list(map(int,input().split()))
# alist = [10,9, 7, 8, 6, 5, 3, 4, 2, 1 ]
count = 0
while alist != sorted(alist):
    temp = [alist[0]]#辅助数组,原数组的第一个数是肯定一直存在的
    for i in range(1,len(alist)):
        if alist[i]>alist[i-1]:
            temp.append(alist[i]) #辅助数组保存该晚上幸存的人
    count += 1
    alist = temp
print(count)

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值