| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 2048 MB | 15 | 11 | 3 | 100.000% |
While wandering around Delft, after a long time in isolation, convinced that nothing could surprise you anymore (after the roller-coaster this year has already been), you encounter yet another peculiarity. From behind a bush, a tiny, friendly-looking alien, reveals himself. Rather confused, he kindly asks you for some help with his new, square shaped spaceship. After bragging about the spaceship’s brand new features, the little alien expresses his worries about the costs of traveling nowadays: "Extraterrestrial economy is down as well, my dear human being!" he protested. "I need to make it to the interdimensional gateway which is across the town but I have scarcely any fuel left in my tank. Could you help me get back home?" Knowing that you are a master of algorithms, he pleads you to compute the minimum amount of power he would need to traverse the city, given that each unit of fuel can lift the spaceship one unit in height.
In order for the spaceship to travel above an area of the city, it should fly overhead all the cells underneath it while going in either of the 4 directions: North, South, East and West.
You also find out that moving the spaceship in any of the cardinal directions does not consume any fuel and that the entirety of the spaceship should be within the map at any given moment (otherwise the alien gets disoriented).
Animated by the desire to help your newly found friend, you get to coding in a heartbeat. Guided by the adventurous computer scientist that you are, you can quickly assess that both the map and the spaceship should be seen as square grids and that each cell of the map has a height (computed relatively to the sea level).
You make the further observations:
The minimum amount of power units that the alien needs for traversing the city with the spaceship.
5 5 2 0 0 1 1 3 0 0 1 1 3 3 3 1 1 3 3 3 1 1 1 3 3 1 1 1
2
6 6 1 0 1 2 3 4 5 0 1 2 3 4 5 0 1 1 1 1 5 0 3 4 5 6 7 0 3 0 0 0 7 0 0 0 1 0 0
1
3 3 2 0 0 7 0 0 7 9 7 9
10