Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def main():
- s_e()
- def s_a():
- a, b, c = tuple([int(x) for x in input().split()])
- result = math.ceil(c*(a-b)/b)
- print(result)
- def s_b():
- n, m = tuple([int(x) for x in input().split()])
- cumsum = [0]
- for i in range(n):
- c, t = tuple([int(x) for x in input().split()])
- cumsum.append(cumsum[i] + c * t)
- v = [int(x) for x in input().split()]
- l = 0
- j = 0
- for i in range(1,n+1):
- while j<m and v[j] <= cumsum[i] :
- print(i)
- j += 1
- def s_c():
- n, m, k, t = tuple([int(x) for x in input().split()])
- waste = []
- qr = []
- for i in range(k):
- x, y = tuple([int(x) for x in input().split()])
- pos = (x-1)*m + y-1
- waste.append(pos)
- waste.sort()
- for i in range(t):
- x, y = tuple([int(x) for x in input().split()])
- pos = (x-1)*m + y-1
- if(pos in waste):
- qr.append('Waste')
- continue
- wastes = searchInsert(waste,pos)
- res = (pos - wastes)%3
- if(res == 0):
- qr.append('Carrots')
- elif (res == 1):
- qr.append('Kiwis')
- elif (res == 2):
- qr.append('Grapes')
- for i in qr:
- print(i)
- def searchInsert(arr, x):
- l = 0
- r = len(arr) - 1
- mid = 0
- while l <= r:
- mid = (l + r) // 2;
- if arr[mid] == x:
- return mid
- elif arr[mid] < x:
- l = mid + 1
- if (r == mid):
- mid = r + 1
- break
- else:
- r = mid - 1
- if (l == mid):
- break
- return mid
- def s_d():
- n = int(input())
- arr = []
- s = 0
- for i in range(n):
- arr.append(int(input()))
- arr.sort()
- for i in range(n):
- s += arr[i] * arr[n-i-1]
- print(s%10007)
- def s_e():
- n = int(input())
- a = [int(x) for x in input().split()]
- m = 1
- ma = []
- l = 1
- prev = 0
- while l< n:
- if(a[l] == a[l-1]):
- m+= 1
- elif(abs(a[l-1] - a[l]) <= 1):
- if(a[prev] == a[l]):
- m+=1
- else:
- ma.append(m)
- prev = l-1
- m = 1
- else:
- ma.append(m)
- prev = l - 1
- m = 1
- l+=1
- print(ma)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement