Description
Twin towers we see you standing tall, though a building’s lost our faith will never fall.
Twin towers the world hears your call, though you’re gone it only strengthens our resolve.
We couldn’t make it through this without you Lord, through hard times we come together more. …
Twin Towers - A Song for America
In memory of the tragic events that unfolded on the morning of September 11, 2001, five-year-old Rosie decids to rebuild a tallest Twin Towers by using the crystals her brother has collected for years. Will she succeed in building the two towers of the same height?
Input
There are mutiple test cases.
One line forms a test case. The first integer N (N < 100) tells you the number of crystals her brother has collected. Then each of the next N integers describs the height of a certain crystal.
A negtive N indicats the end.
Note that all crytals are in cube shape. And the total height of crystals is smaller than 2000.
Output
If it is impossible, you would say “Sorry”, otherwise tell her the height of the Twin Towers.
Sample Input
4 11 11 11 11
4 1 11 111 1111
-1
Sample Output
22
Sorry
給你一些東西的高度。。然後問你用這些可不可以組成兩個高度一樣的塔。。
dp[a][b] 第a個石頭,,兩塔的高度差。。不斷地去維護低塔。。
#include
#include
#include
#include
#include
#include
#include
#include
後來又發現了可以再優化。。。。。
用滾動數組優化內存(雖然並沒有什麼卵用)(給自己提個醒,有這個用法吧)
#include
#include
#include
#include
#include
#include
#include
#include