Balanced Lineup (线段树)

For the daily milking, Farmer John’sNcows (1 ≤N≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things simple, he will take a contiguous range of cows from the milking lineup to play the game. However, for all the cows to have fun they should not differ too much in height.

Farmer John has made a list ofQ(1 ≤Q≤ 200,000) potential groups of cows and their heights (1 ≤height≤ 1,000,000). For each group, he wants your help to determine the difference in height between the shortest and the tallest cow in the group.

,旅游,放松心情,用眼睛享受风景。

Balanced Lineup (线段树)

相关文章:

你感兴趣的文章:

标签云: