minimario

SRM 320 Div 2. Hard

Jun 4th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. class ContestSchedule():
  2.     def expectedWinnings(self, x):
  3.         t = []
  4.         x = list(x)
  5.         for i in x:
  6.             a, b, c = map(int, i.split(' '))
  7.             c = c / 100.0
  8.             t.append([a,b,c])
  9.  
  10.         t.sort(key = lambda x:x[1])
  11.  
  12.         dp = [0] * len(x)
  13.         for i in range(len(x)):
  14.             dp[i] = t[i][2]
  15.  
  16.         for i in range(1, len(t)):
  17.             for j in range(i):
  18.                 a1, a2, b1, b2 = t[i][0], t[i][1], t[j][0], t[j][1]
  19.                 if a2 <= b1 or b2 <= a1:
  20.                     dp[i] = max(dp[i], t[i][2] + dp[j])
  21.                    
  22.         return max(dp)
Advertisement
Add Comment
Please, Sign In to add comment