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

30565번 - History in Numbers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB837713.462%

문제

Algorithms and data structures find their place in various arts, crafts, and sciences. In this problem, we are discussing one potential application in history.

Historians are studying the urban development of a city over a period of $n$ years. The urban development is quantified using an aggregate measure they call an urban development index (UDI), which could take integer values, including negative. There is an initial estimation $e_i$ of this index for each of the years. However, during the research process, due to the new documents and evidence discovered, these estimates are revised and updated. More formally, throughout the historians' work process, they could want to update the UDI estimates for all years between $s_j$ and $f_j$ (inclusive) by adding $d_j$ to each of them.

The main question historians are interested in is if the UDI has been increasing over a certain period of time. However, due to the noisy nature of estimates, we will not be using the standard definition. Instead, the following procedure is used:

  • we collapse all consequent equal numbers into one. For instance, 1 1 2 2 2 3 3 3 becomes 1 2 3;
  • the UDI is considered increasing from year $i$ to year $j$ if the sequence of local minima in the UDI sequence after the above transformation is strictly increasing. An element $p_i$ is considered to be a local minimum if it is less than both of its neighbors (one neighbor for the first or last element).

You are to implement the system able to store the UDI estimates and process the requests to update them and to check if the UDI has been increasing over a certain period.

입력

  • One line containining an integer $n$ (1ドル \le n \le 3 \cdot 10^5$) denoting the length of the time period being considered.
  • One line containing $n$ space separated integers $e_i$ ($-10^8 \le e_i \le 10^8$).
  • One line containing an integer number $m$ (1ドル \le m \le 3 \cdot 10^5$).
  • $m$ further lines each describing one request in one of the following two formats:
    • update followed by three integers $s_j,ドル $f_j,ドル and $d_j$ (1ドル \le s_j \le f_j \le n,ドル $|d_j| \le 10^8$).
    • check followed by two integers $s$ and $f$ (1ドル \le s \le f \le n$).

출력

For each check request output YES if the UDI has been increasing during the corresponding period and NO otherwise.

제한

예제 입력 1

5
10 4 10 6 10
5
check 1 5
update 2 3 1
check 1 5
update 2 3 1
check 1 5

예제 출력 1

YES
YES
NO

예제 입력 2

8
10 -5 -5 -5 11 6 6 12
1
check 1 8

예제 출력 2

YES

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2023 H번

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

출처

대학교 대회

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

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