Skip to content

Instantly share code, notes, and snippets.

@niyarin
Created June 5, 2014 08:21
Show Gist options
  • Save niyarin/6b3de2ed3d496c62ed1a to your computer and use it in GitHub Desktop.
Save niyarin/6b3de2ed3d496c62ed1a to your computer and use it in GitHub Desktop.
n = input()
cow_list = []
def eated_flower(list,time,cnt=0):
num = 0
for l in list:
num += l[1 + cnt] * time
return num
c2 = []
for i in range(n):
c = raw_input().split(" ")
c2.append( [int(c[0]),int(c[1])] )
for i in range(n):
cow_list.append([float(c2[i][1]) / c2[i][0],c2[i][0],c2[i][1] ] )
cow_list.sort()
cow_list.reverse()
ans = 0
for i in range(len(cow_list)):
ans += eated_flower(cow_list[i+1:len(cow_list)],cow_list[i][1] * 2,1)
print ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment