# UVa 11039

Jump to navigation
Jump to search

## 11039 - Building designing[edit]

## Summary[edit]

This is a simple problem that can be solved with a greedy algorithm.

## Explanation[edit]

First, sort the red and the blue independently. Then try the two scenarios - with a red as the base, and blue as the base and alternatively puts the biggest block that can fit on top of the previous piece. Take the higher of the buildings.

## Input[edit]

2 5 7 -2 6 9 -3 8 11 -9 2 5 18 17 -15 4

## Output[edit]

2 5