[Solution] Also Try Minecraft Codeforces Solution
You are beta testing the new secret Terraria update. This update will add quests to the game!
Simply, the world map can be represented as an array of length , where the -th column of the world has height .
There are quests you have to test. The -th of them is represented by two integers and . In this quest, you have to go from the column to the column . At the start of the quest, you are appearing at the column .
In one move, you can go from the column to the column or to the column . In this version, you have Spectre Boots, which allow you to fly. Since it is a beta version, they are bugged, so they only allow you to fly when you are going up and have infinite fly duration. When you are moving from the column with the height to the column with the height , then you get some amount of fall damage. If the height is
greater than the height , you get fall damage, otherwise you fly up and get damage.
For each of the given quests, determine the minimum amount of fall damage you can get during this quest.
The first line of the input contains two integers and () — the number of columns in the world and the number of quests you have to test, respectively.
Three Doors Codeforces Solution 2022
Also Try Minecraft Codeforces Solution
Recover an RBS Codeforces Solution
Rorororobot Codeforces Solution
Multiset of Strings Codeforces Solution
The second line of the input contains integers (), where is the height of the -th column of the world.
The next lines describe quests. The -th of them contains two integers and (), which means you have to move from the column to the column during the -th quest.
Note that can be greater than .
Print integers. The -th of them should be the minimum amount of fall damage you can get during the -th quest completion.
No comments:
Post a Comment