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

34592번 - Reactor 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 2048 MB28171659.259%

문제

In a high-tech industrial facility, a series of nuclear reactors are arranged in a linear configuration. Each reactor operates under strict pressure regulations to ensure safety and efficiency. To prevent critical failures, each reactor has a specific maximum pressure limit. When a reactor’s internal pressure reaches or exceeds this limit, a controlled pressure release (venting) is initiated. This system requires sophisticated management due to dynamic operational adjustments and the need for continuous monitoring.

You are tasked with designing and implementing a system to manage the pressure of a line of $n$ reactors. Each reactor, indexed from 1ドル$ to $n,ドル has an initial maximum pressure limit $p_i$. All of the reactors’ initial pressure are 0ドル$. The system must support two types of operations:

  1. Pressure Increase Operation: For a given range of reactors $[l, r],ドル increase their pressure by $k$ units. If the pressure of any reactor in this range reaches or exceeds its maximum limit, it will vent, resetting its pressure to 0ドル$. And the maximum pressure limit of the vented reactor will be updated to $\max{(\left\lfloor \frac{P_{old}}{2} \right\rfloor, 1)},ドル where $p_{old}$ is the maximum pressure limit of the reactor before the current pressure increase operation.
  2. Venting Count Query: For a given range of reactors $[l, r],ドル you need to report the total number of venting operations that have occurred among all reactors within this specified range since the beginning of the system’s operation.

입력

The first line contains two integers $n$ and $q,ドル representing the number of reactors and the number of operations, respectively.

The second line contains $n$ integers, the $i$-th integer $p_i$ represents the initial maximum pressure limit of the $i$-th reactor.

The following $q$ lines describe the operations. Each line begins with an integer $op$.

  • If $op = 1,ドル it is followed by three integers $l,ドル $r,ドル and $k,ドル representing a pressure increase operation on the range of reactors from $l$ to $r$ (inclusive) by $k$ units.
  • If $op = 2,ドル it is followed by two integers $l$ and $r,ドル representing a venting count query for the range of reactors from $l$ to $r$ (inclusive).

출력

For each query that $op = 2,ドル print a single integer on a new line, representing the total number of venting operations that have occurred among all reactors within the specified range since the beginning of the system’s operation.

제한

  • 1ドル ≤ n ≤ 2 \times 10^5$
  • 1ドル ≤ q ≤ 2 \times 10^5$
  • 1ドル ≤ p_i ≤ 4 \times 10^5$
  • 1ドル ≤ l ≤ r ≤ n$
  • 1ドル ≤ k ≤ 4 \times 10^5$
  • It is guaranteed that there is at least one Venting Count Query.

예제 입력 1

10 5
5 10 23 45 10 45 65 10 68 9
1 5 10 664
1 2 9 5
2 4 10
1 8 8 5
2 1 10

예제 출력 1

8
9

예제 입력 2

10 10
79 26 9 28 13 40 26 54 69 19
1 1 5 6
1 5 7 2
2 4 7
1 9 10 19
2 5 7
1 5 7 27
2 10 10
2 9 9
1 6 6 20
1 3 8 6

예제 출력 2

0
0
1
0

예제 입력 3

10 10
56 29 49 42 47 21 23 54 8 31
2 9 9
1 5 6 23
2 6 7
2 4 7
1 5 6 68
2 1 9
2 3 6
1 2 10 89
2 6 8
1 3 6 53

예제 출력 3

0
1
1
3
3
5

노트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2025 I번

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

출처

대학교 대회

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

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