Skip to content

Instantly share code, notes, and snippets.

@muthhukumar
Created August 16, 2020 07:29
Show Gist options
  • Save muthhukumar/7d26bb9780973888fe9039aa43336fe0 to your computer and use it in GitHub Desktop.
Save muthhukumar/7d26bb9780973888fe9039aa43336fe0 to your computer and use it in GitHub Desktop.
#g = int(input())
#b, h = map(int, input().split())
m = pow(10,9)+7
#l = list(map(int, input().split()))
g = 7
b, h = 1, 1
l = [6, 7, 3, 4, 5, 1, 3]
sumof = sum(l)
res = 0
ans = 0
stack = []
count = -1
for i in range(g):
while count != -1 and l[i] <= l[stack[count]]:
temp = stack[count]
count -= 1
res = l[temp] * (i if count == -1 else (i - stack[count] -1 ))
ans = ans % m if ans % m > res else res
count += 1
print(stack[count])
stack[count] = i
while count != -1:
temp = stack[count]
count -= 1
res = l[temp] * (i if count == -1 else (i - stack[count] - 1))
ans = ans % m if ans % m > res else res
print(((sumof % m - ans % m) % m * b % m * h % m) % m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment