zogzog

Untitled

Jun 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import sys
  2.  
  3. ontrain = 0
  4. x = sys.stdin.readline()
  5. y = x.split()
  6. cap = int(y[0])
  7. b = int(y[1])
  8.  
  9. for i in range(0, b):
  10.   z = sys.stdin.readline()
  11.   g = z.split()
  12.   left = int(g[0])
  13.   enter = int(g[1])
  14.   stay = int(g[2])
  15.   print(g)
  16.  
  17.   if left > ontrain:
  18.       print("impossible")
  19.       break
  20.  
  21.   if enter+ontrain >= cap+1:
  22.       print("impossible")
  23.       break
  24.   else:
  25.       ontrain += enter
  26.       ontrain -= left
  27.      
  28.   space = cap-ontrain
  29.   print(space)
  30.  
  31.   if i == b-1 and ontrain > 0:
  32.    print("impossible")
  33.    break
  34.   elif i == b-1 and stay > 0:
  35.     print("impossible")
  36.     break
  37.   elif i is not b-1 and space > 0 and stay > 0:
  38.     print("impossible")
  39.     break
  40.   elif i == b-1:
  41.    print("possible")
  42.    break
Advertisement
Add Comment
Please, Sign In to add comment