Sunday, 23 December 2018

Hanging Posters Hacker Rank solution in python3

Problem:
https://www.hackerrank.com/contests/hourrank-31/challenges/hanging-posters/problem

Solution:
#!/bin/python3

from math import *

n,h=map(int, input().split())
wp = list(map(int, input().split()))
pl = list(map(int, input().split()))
ans=0
for i in range(n):
    if wp[i] <= h:
        temp=0
    else:
        temp = wp[i]+pl[i]*1/4  #height of top of the poster from ground level
        temp=temp-pl[i]*1/2-h   #reduce the height of arthur and half of height of poster
   
    if ans<temp:
        ans=temp
print(ceil(ans))       


No comments:

Post a Comment