Advertisement
Bad_Programist

Untitled

Feb 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. from collections import deque
  2. N, K, P = list(map(int, input().split()))
  3. Barja = [deque()] * K
  4. res = 0
  5. for i in range(N):
  6.     S = input().split()
  7.     r = 0
  8.     S[1], S[2] = int(S[1]), int(S[2])
  9.     if S[0] == '+':
  10.         Barja[S[1] - 1].append(S[2])
  11.     elif len(Barja[S[1] - 1]) > 0 and Barja[S[1] - 1][-1] == S[2]:
  12.         Barja[S[1] - 1].pop()
  13.     else:
  14.         res = False
  15.         break
  16.     for i in Barja:
  17.         r += len(i)
  18.     if r > res:
  19.         res = r
  20. if res:
  21.     print(res)
  22. else:
  23.     print('Error')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement