QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#344751#5481. Beast Bulliesmfshi03WA 512ms56380kbPython3651b2024-03-05 05:40:352024-03-05 05:40:37

Judging History

你现在查看的是最新测评结果

  • [2024-03-05 05:40:37]
  • 评测
  • 测评结果:WA
  • 用时:512ms
  • 内存:56380kb
  • [2024-03-05 05:40:35]
  • 提交

answer

def solve(strengths):
    strengths.sort()
    n = len(strengths)
    
    # Calculate the prefix sums of strengths
    prefix_sums = [0] * (n + 1)
    for i in range(n):
        prefix_sums[i + 1] = prefix_sums[i] + strengths[i]
    
    # Find the number of animals that will remain
    remaining = 0
    for i in range(n):
        if prefix_sums[i] > prefix_sums[n] - prefix_sums[i + 1]:
            remaining = n - i
            break
    
    return remaining

# Read the input
n = int(input())
strengths = [int(input()) for _ in range(n)]

# Solve the problem
result = solve(strengths)

# Print the output
print(result)

詳細信息

Test #1:

score: 0
Wrong Answer
time: 512ms
memory: 56380kb

input:

500000
976631732
51389671
729809897
630844317
294721017
903231515
477913449
871071076
636104080
345822085
97441187
499323378
522845426
310022664
199310190
776622973
602672555
646874222
214723272
285341530
962727359
681361226
47426538
272153520
693133904
542337627
556307610
325596239
95738088
5495543...

output:

146256

result:

wrong answer 1st lines differ - expected: '155101', found: '146256'