Problem p03038 (python)

Fixed submission:
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
for x in alis:
    lis.append([1,x])
lis.sort(reverse=True,key=lambda x:x[1])
ans = 0
for x in lis:
    (number,point) = x
    if number >= n:
        number = n
        ans += number * point
        #print(n)
        #print(ans,'+=',number,'*',point)
        break
    ans += number * point
    n -= number
    #print(n)
    #print(ans,'+=',number,'*',point)
print(ans)
#print(lis)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis = [x for y in clis for x in y]
clis.sort(reverse=True)
alis.sort()
ans_lis=[x if x>=y else y for x,y in zip(alis,clis)]
ans = 0
for x,y in zip(alis,clis):
    ans += max(x,y)
if n>l:
    ans += sum(alis[l:])
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis = [x for y in clis for x in y]
clis.sort(reverse=True)
l = len(clis)
alis.sort()
ans = 0
for x,y in zip(alis,clis):
    if x>=y:
        ans += x
    else:
        ans += y
print(a)
if n>l:
    ans += sum(alis[l:])
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [x[1]*x[0] for x in lis]
clis = [x for y in clis for x in y]
clis.sort(reverse=True)
alis.sort()
ans = 0
for x,y in zip(alis,clis):
    if x>=y:
        ans += x
    else:
        ans += y
print(p)
if len(clis) < len(alis):
    ans__ = sum(alis[len(clis):])
    ans += ans__
    print(ans)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [x[1]*x[0] for x in lis]
clis = [x for y in clis for x in y]
clis.sort(reverse=True)
alis.sort()
print(p)
ans = 0
for x,y in zip(alis,clis):
    if x>=y:
        ans += x
    else:
        ans += y
if len(clis) < len(alis):
    ans__ = sum(alis[len(clis):])
    ans += ans__
    print(ans)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis = [x for y in clis for x in y]
clis.sort(reverse=True)
alis.sort()
for x,y in zip(alis,clis):
    if x>=y:
        ans += x
    else:
        ans += y
if len(clis) < len(alis):
    ans__ = sum(alis[len(clis):])
    ans += ans__
    print(ans)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis = [x for y in clis for x in y]
clis.sort(reverse=True)
alis.sort()
ans_lis=[x if x>=y else y for x,y in zip(alis,clis)]
print(a)
if len(clis) < len(alis):
    ans__ = sum(alis[len(clis):])
    ans_=sum(ans_lis)
    print(ans_+ans__)
else:
    print(sum(ans_lis))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis = [x for y in clis for x in y]
clis.sort(reverse=True)
alis.sort()
ans_lis=[x if x>=y else y for x,y in zip(alis,clis)]
if len(clis) < len(alis):
    ans__ = sum(alis[len(clis):])
    ans_=sum(ans_lis)
    print(ans_+ans__)
    print(a)
else:
    print(sum(ans_lis))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis = [[x for x in y]for y in clis]
clis.sort(reverse=True)
alis.sort()
ans_lis=[x if x>=y else y for x,y in zip(alis,clis)]
if len(clis) < len(alis):
    ans__ = sum(alis[len(clis):])
    ans_=sum(ans_lis)
    print(ans_+ans__)
else:
    print(sum(ans_lis))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis=(sum(clis,[]))
clis.sort(reverse=True)
alis.sort()
print(a)
ans_lis=[x if x>=y else y for x,y in zip(alis,clis)]
if len(clis) < len(alis):
    ans__ = sum(alis[len(clis):])
    ans_=sum(ans_lis)
    print(ans_+ans__)
else:
    print(sum(ans_lis))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis=(sum(clis,[]))
clis.sort(reverse=True)
alis.sort()
ans_lis=[x if x>=y else y for x,y in zip(alis,clis)]
if len(clis) < len(alis):
    ans__ = sum(alis[num:])
    print(sum(ans_lis,ans__))
else:
    print(sum(ans_lis))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis=(sum(clis,[]))
clis.sort(reverse=True)
alis.sort()
ans_lis=[x if x>=y else y for x,y in zip(alis,clis)]
if len(clis) < len(alis):
    ans__ = sum(alis[num:])
    print(sum(ans_lis,ans__))
else:
    print(sum(ans_lis))