Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- ontrain = 0
- x = sys.stdin.readline()
- y = x.split()
- cap = int(y[0])
- b = int(y[1])
- for i in range(0, b):
- z = sys.stdin.readline()
- g = z.split()
- left = int(g[0])
- enter = int(g[1])
- stay = int(g[2])
- print(g)
- if left > ontrain:
- print("impossible")
- break
- if enter+ontrain >= cap+1:
- print("impossible")
- break
- else:
- ontrain += enter
- ontrain -= left
- space = cap-ontrain
- print(space)
- if i == b-1 and ontrain > 0:
- print("impossible")
- break
- elif i == b-1 and stay > 0:
- print("impossible")
- break
- elif i is not b-1 and space > 0 and stay > 0:
- print("impossible")
- break
- elif i == b-1:
- print("possible")
- break
Advertisement
Add Comment
Please, Sign In to add comment