Logo
(追記) (追記ここまで)

11962번 - Counting Haybales 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB83834526542.265%

문제

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 \(N\) fields in a row, conveniently numbered \(1 \ldots N\). In each field there can be any number of haybales. Farmer John's instructions contain three types of entries:

1) Given a contiguous interval of fields, add a new haybale to each field.

2) Given a contiguous interval of fields, determine the minimum number of haybales in a field within that interval.

3) Given a contiguous interval of fields, count the total number of haybales inside that interval.

입력

The first line contains two positive integers, \(N\) (\(1 \leq N \leq 200,000\)) and \(Q\) (\(1 \leq Q \leq 100,000\)).

The next line contains \(N\) nonnegative integers, each at most 100,000, indicating how many haybales are initially in each field.

Each of the next \(Q\) lines contains a single uppercase letter, either M, P or S, followed by either two positive integers \(A\) and \(B\) (\(1 \leq A \leq B \leq N\)), or three positive integers \(A\), \(B\), and \(C\) (\(1 \leq A \leq B \leq N\); \(1 \leq C \leq 100,000\)). 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 \(A \ldots B\).

If the letter is P, put \(C\) new haybales in each field in the interval of fields from \(A \ldots B\).

If the letter is S, print the total number of haybales found within interval of fields from \(A \ldots B\).

출력

A line in the output should appear in response to every 'M' or 'S' entry in FJ's instructions.

제한

예제 입력 1

4 5
3 1 2 4
M 3 4
S 1 3
P 2 3 1
M 3 4
S 1 3

예제 출력 1

2
6
3
8

힌트

출처

Olympiad > USA Computing Olympiad > 2015-2016 Season > USACO December 2015 Contest > Platinum 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /