Advertisement
ilyakanyshev

D

Oct 13th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. n = int(input())
  2. balls = [0]*501
  3. user = {}
  4. countUser = 0
  5. for _ in range(n):
  6.     query = input().split()
  7.     if query[0] == 'ACHIEVE':
  8.         try:
  9.             user[int(query[1])] += 0
  10.             balls[user[int(query[1])]] -= 1
  11.         except:
  12.             countUser += 1
  13.         user[int(query[1])] = int(query[2])
  14.         balls[int(query[2])] += 1
  15.     elif query[0] == 'RATING':
  16.         try:
  17.             print("%.6f" % ((sum(balls[:user[int(query[1])]]))/(countUser-1)))
  18.         except:
  19.             try:
  20.                 balls[user[int(query[1])]] += 0
  21.                 print('1.000000')
  22.             except:
  23.                 print('0.000000')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement