9.21华为笔试 T1一直过10%,求大佬帮忙指正
def func(): n = int(input()) nums = list(map(lambda x: int(x), input().split(' '))) t = int(input()) if sum(nums) <= t: # print(-1) return -1 nums.sort() if nums[0] * n > t: # print(t // len(nums)) return t // n ans = 1 cur_sum = 0 for i, num in enumerate(nums): cur_sum += num if cur_sum + num * (n - i - 1) > t: gap = t - (cur_sum - num) ans = gap // (n - i) break return ans if __name__ == "__main__": print(func())
#华为笔试#