#P3130. [USACO15DEC] Counting Haybale P
[USACO15DEC] Counting Haybale P
题目描述
Farmer John is trying to hire contractors to help rearrange his farm, but so far all of them have quit when they saw the complicated sequence of instructions FJ wanted them to follow. Left to complete the project by himself, he realizes that indeed, he has made the project perhaps more complicated than necessary. Please help him follow his instructions to complete the farm upgrade.
FJ's farm consists of fields in a row, conveniently numbered . In each field there can be any number of haybales. Farmer John's instructions contain three types of entries:
-
Given a contiguous interval of fields, add a new haybale to each field.
-
Given a contiguous interval of fields, determine the minimum number of haybales in a field within that interval.
-
Given a contiguous interval of fields, count the total number of haybales inside that interval.
输入格式
The first line contains two positive integers, () and
().
The next line contains nonnegative integers, each at most 100,000,
indicating how many haybales are initially in each field.
Each of the next lines contains a single uppercase letter, either M, P or S,
followed by either two positive integers and (),
or three positive integers , , and (;
). There will be three positive integers if and only if
the uppercase letter is P.
If the letter is M, print the minimum number of haybales in the interval of fields
from .
If the letter is P, put new haybales in each field in the interval of fields
from .
If the letter is S, print the total number of haybales found within interval of
fields from .
输出格式
A line in the output should appear in response to every 'M' or 'S' entry in FJ's
instructions.
题目大意
FJ 想雇佣几个人在他的农场里帮忙,他需要进行很多种操作,请你帮他搞定。
FJ 的农场有 块排成一行的田地,编号从 到 。每一块田地都有很多草包。FJ 要进行下面几种操作:
-
给定一段连续的田地,给每一块田地都增加一些新的草包。
-
给定一段连续的田地,找出草包最少的田地有多少草包。
-
给定一段连续的田地,统计一共有多少草包。
4 5
3 1 2 4
M 3 4
S 1 3
P 2 3 1
M 3 4
S 1 3
2
6
3
8