N,M=map(int,input().split())
A=[]
k=int(input())
for i in range(M*N):
a=list(map(int,input().split()))
A.append(a)
k1=key=A[k][1]
j=k
for n in range(N-1):
s=0
while s<k1:
if j==M:
j=0
else:
if A[j+M*n][0]==1:
j+=1
s+=1
else:
j+=1
s=s
j=j-1
k1=A[j+M*(n+1)][1]
key+=k1
print(key)
在oj上屢次爆表
求大佬幫我縮短運行時間
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/133203.html
