请大佬留下代码,下面是写的代码,但是有错,有没有知道错哪里的大佬,或者有没有更简约的,展示一下,谢谢大佬
import sys
import re
class Node:
def __init__(self,data = None, next = None):
self.data = data
self.next = next
class Queue:
def __init__(self):
self.head = Node()
self.tail = self.head
def put(self,n):
self.tail.next = Node(n)
self.tail = self.tail.next
def get(self):
return self.head.next.data
def delete(self):
g = self.head
g.next = g.next.next
if g.next==None:
self.tail = g
def funcname():
s = sys.stdin.readline()
r = re.findall(r'd+', s)
bridgelength = int(r[0])
bridgeload = int(r[1])
br = Queue()
num = 1
sw = 0
sl = 0
while True:
s = sys.stdin.readline()
if s=="":
break
r = re.findall(r'd+', s)
for i in range(0,len(r),2):
l = int(r[i])
w = int(r[i+1])
sw += w
sl += l
br.put([num,l,w])
while sl-br.get()[1] >= bridgelength:
t = br.get()
sl -= t[1]
sw -= t[2]
br.delete()
if sw>bridgeload:
print(br.get()[0])
return
num += 1
print(-1)
funcname()
以上是 请大佬留下代码,下面是写的代码,但是有错,有没有知道错哪里的大佬,或者有没有更简约的,展示一下,谢谢大佬 的全部内容, 来源链接: utcz.com/p/937892.html