Created
          July 18, 2014 13:01 
        
      - 
      
- 
        Save cocodrips/5fcbe15d6839410d475d to your computer and use it in GitHub Desktop. 
    SRM624 Div1 Easy in python
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class BuildingHeights: | |
| """ 4000 ** 2 -> T L E""" | |
| def minimum(self, heights): | |
| N = len(heights) | |
| heights = list(heights) | |
| heights.sort() | |
| sums = [0 for _ in xrange(N+1)] | |
| for i in xrange(N): | |
| sums[i+1] = sums[i] + heights[i] | |
| result = 0 | |
| for n in xrange(2, N + 1): | |
| mini = 1000000000 | |
| for l in xrange(N - n + 1): | |
| mini = min(mini, heights[l + n - 1] * n - (sums[l + n] - sums[l])) | |
| result ^= mini | |
| return result | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment