GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Thursday 21 July 2022

[Solution] Also Try Minecraft Codeforces Solution



B. Also Try Minecraft
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 n, where the i-th column of the world has height ai.

There are m quests you have to test. The j-th of them is represented by two integers sj and tj. In this quest, you have to go from the column sj to the column tj. At the start of the quest, you are appearing at the column sj.

In one move, you can go from the column x to the column x1 or to the column x+1. 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 p to the column with the height q, then you get some amount of fall damage. If the height p is

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

 greater than the height q, you get pq fall damage, otherwise you fly up and get 0 damage.

For each of the given quests, determine the minimum amount of fall damage you can get during this quest.

Input

The first line of the input contains two integers n and m (2n105;1m105) — 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 

XOR Tree Codeforces Solution

Multiset of Strings Codeforces Solution

The second line of the input contains n integers a1,a2,,an (1ai109), where ai is the height of the i-th column of the world.

The next m lines describe quests. The j-th of them contains two integers sj and tj (1sj,tjn;sjtj), which means you have to move from the column sj to the column tj during the j-th quest.

Note that sj can be greater than tj.

Output

Print m integers. The j-th of them should be the minimum amount of fall damage you can get during the j-th quest completion.

No comments:

Post a Comment