QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#714875#7695. Double UpdagworthWA 15ms10696kbPython3887b2024-11-06 08:51:162024-11-06 08:51:16

Judging History

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

  • [2024-11-06 08:51:16]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:10696kb
  • [2024-11-06 08:51:16]
  • 提交

answer

input()
arr = list(int(n) for n in input().split(" "))
biggest = max(arr)

def fix():
    index = 0
    while index+1 < len(arr):
        if arr[index] == arr[index+1]:
            arr[index]*=2
            arr.pop(index+1)
            index-=1
        index+=1

num = 1
while num < biggest:
    fix()
    other = -1
    i = 0
    while i < len(arr):
        if arr[i] == num:
            if other == -1:
                other = i
            else:
                index = other
                sum = 0
                while index < i and sum < 2*num:
                    sum+=arr[index]
                    index+=1
                if sum >= 2*num:
                    arr.pop(i)
                    arr.pop(other)
                    i-=2
                other = -1
        i+=1
    if other != -1:
        arr.pop(other)
    num*=2

print(arr[0])

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 9ms
memory: 10696kb

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

score: -100
Wrong Answer
time: 15ms
memory: 10628kb

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1

result:

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