QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#714879#7695. Double UpdagworthWA 7ms10648kbPython3914b2024-11-06 08:54:282024-11-06 08:54:28

Judging History

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

  • [2024-11-06 08:54:28]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:10648kb
  • [2024-11-06 08:54:28]
  • 提交

answer

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

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

fix()
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: 0
Wrong Answer
time: 7ms
memory: 10648kb

input:

5
4 2 2 1 8

output:

[4, 2, 2, 1, 8]
[4, 2, 2, 1, 8]
[4, 4, 1, 8]
[8, 1, 8]
[1, 16]
[1, 16]
[1, 16]
[1, 16]
16

result:

wrong answer 1st lines differ - expected: '16', found: '[4, 2, 2, 1, 8]'