Film festival

LucarnosFilm Festival is an annual film festival and is also known for being a prestigious platform for art house films. This time at the Lucarnos Film festival there are N movies screened, each of different genre ranging from drama movies to comedy ones and teen movies to horror ones. Lucy is a huge fan of movies and visited the film festival, but she's not sure which movie she should watch. Each movie can be characterized by two integers Li and Ri, denoting the length and the rating of the corresponding movie. Lucy wants to watch exactly one movie with the maximal value of Li × Ri. If there are several such movies, she would pick a one with the maximal Ri among them. If there is still a tie, she would pick the one with the minimal index among them. Write a program to help Lucy pick a movie to watch at the film festival. Input Format: The first line of the input description contains an integer n. Assume that the maximum value for n as 50. The second line of the input description contains n integers L1, L2, ...,Ln. The following line contains n integers R1, R2, ...,Rn. Output Format: Output a single integer i denoting the index of the movie that Lucy should watch in the film festival. Note that you follow 1-based indexing. Refer sample input and output for formatting specifications. Sample Input 1: 2 1 2 2 1 Sample Output 1: 1 Sample Input 2: 4 2 1 4 1 2 4 1 4 Sample Output 2: 2 n=int(input()) l=list(map(int,input().split())) r=list(map(int,input().split())) e=[] for i in range(n): e.append(l[i]*r[i]) m=max(e) p,o=list(),list() for i in range(n): if e[i]==m: p.append(i) o.append(r[i]) r=max(o) for i in range(len(p)): if o[i]==r: print(p[i]+1) break

No comments:

Post a Comment