Advertisement
1nikitas

Untitled

Mar 23rd, 2022
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. def make_shades(alley, k):
  2.     d = len(alley)
  3.     shades = [False] * d
  4.     for i in range(d):
  5.         height = alley[i]
  6.         if height > 0:
  7.             if k >= 0:
  8.                 start = i
  9.                 finish = min(i + k * height, d - 1)
  10.             else:
  11.                 start = max(i + k * height, 0)
  12.                 finish = i
  13.             for j in range(start, finish + 1):
  14.                 shades[j] = True
  15.     return shades
  16.  
  17.  
  18. def calculate_sunny_length(shades):
  19.     sum_ = 0
  20.     for i in shades:
  21.         sum_ += 1 if i else 0
  22.        
  23.     return len(shades) - sum_
  24.  
  25.  
  26. def main():
  27.     k = int(input())
  28.     alley = [int(height) for height in input().split()]
  29.     shades = make_shades(alley, k)
  30.     print('Обгорел' if calculate_sunny_length(shades) >= 10 else 'Тени достаточно')
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement