Problem p03103 (python)

Fixed submission:
N,M = map(int,input().split())
li = [list(map(int,input().split())) for i in range(N)]
li=sorted(li,key=lambda x: x[0])
m_sum=0
for i in li:
	buy=min(M,i[1])
	m_sum+=i[0]*buy
	M-=buy
print(m_sum)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
li = [list(map(int, input().split())) for i in range(N)]
li = sorted(li, key=lambda x: x[0])
m_sum = 0
for i in li:
    buy = min(M, i[i])
    m_sum += i[0]*buy
    M -= buy
print(m_sum)
# A = []
# B = []
# for i in range(N):
#     A_i, B_i = map(int, input().split())
#     A.append(A_i)
#     B.append(B_i)

# min_value_index_list = np.argsort(A)

# cnt = 0
# result = 0
# for i in range(N):
#     cnt += B[min_value_index_list[i]]
#     if M - cnt >= 0:
#         result += A[min_value_index_list[i]] * B[min_value_index_list[i]]
#         goal = M - cnt
#     else:
#         result += A[min_value_index_list[i]] * goal
#         break
# print(result)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A_i, B_i = map(int, input().split())
    A.append(A_i)
    B.append(B_i)

min_value_index_list = np.argsort(A)

cnt = 0
result = 0
for i in range(N):
    cnt += B[min_value_index_list[i]]
    if M - cnt > 0:
        result += A[min_value_index_list[i]] * B[min_value_index_list[i]]
        goal = M - cnt
    else:
        result += A[min_value_index_list[i]] * goal
        break
print(result)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A_i, B_i = map(int, input().split())
    A.append(A_i)
    B.append(B_i)

min_value_index_list = np.argsort(A)

cnt = 0
result = 0
for i in range(N):
    cnt += B[min_value_index_list[i]]
    if M - cnt >= 0:
        result += A[min_value_index_list[i]] * B[min_value_index_list[i]]
        goal = M - cnt
    else:
        result += A[min_value_index_list[i]] * goal
        break
print(result)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A_i, B_i = map(int, input().split())
    A.append(A_i)
    B.append(B_i)

min_value_index_list = np.argsort(A)

cnt = 0
result = 0
for i in range(N):
    cnt += B[min_value_index_list[i]]
    print(cnt)
    if M - cnt >= 0:
        result += A[min_value_index_list[i]] * B[min_value_index_list[i]]
        goal = M - cnt
    else:
        result += A[min_value_index_list[i]] * goal
        break
print(result)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A_i, B_i = map(int, input().split())
    A.append(A_i)
    B.append(B_i)

min_value_index_list = np.argsort(A)

cnt = 0
for i in range(len(min_value_index_list)):
    if cnt+B[min_value_index_list[i]] < M:
        result = A[min_value_index_list[i]] * B[min_value_index_list[i]]
        cnt += B[min_value_index_list[i]]
    elif cnt+B[min_value_index_list[i]] > M:
        result = A[min_value_index_list[i]] * M
print(result)