Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #coding: utf-8
  2.  
  3. # Задача 27.110
  4.  
  5. N = int(input())
  6.  
  7. mx = l = r = l3 = r3 = 0
  8. for i in range(N):
  9.     x = int(input())
  10.     if x > mx:
  11.         if mx > 0:
  12.             if mx % 3 == 0:
  13.                 l3 += 1
  14.             else:
  15.                 l += 1
  16.         mx = x
  17.         l3 += r3
  18.         l += r
  19.         r3 = r = 0
  20.     elif x % 3 == 0:
  21.         r3 += 1
  22.     else:
  23.         r += 1
  24.        
  25. print(l3 * r3 + l3 * r + r3 * l)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement