Educational Segment Tree Contest - ITLAZY

View as PDF

Submit solution

Points: 0.15
Time limit: 2.0s
Memory limit: 256M
Input: stdin
Output: stdout

Problem source:
Educational Segment Tree Contest - Anh Long
Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

Bạn được cho một mảng gồm ~n~ số nguyên. Nhiệm vụ của bạn là xử lí 2 loại truy vấn:

  • Loại 1 có dạng ~1~ ~x~ ~y~ ~val~: Tăng giá trị của các phần tử từ vị trí thứ ~x~ đến vị trí thứ ~y~ trong dãy lên ~val~ đơn vị (~1\le x \le y \le n,1\le val\le10^9~)
  • Loại 2 có dạng ~2~ ~l~ ~r~: In ra phần tử lớn nhất của dãy từ phần tử thứ ~l~ đến phần tử thứ ~r~ (~1\le l\le r\le n~)

Với mỗi truy vấn loại 2, hãy in ra câu trả lời trên một dòng.

Input

  • Dòng đầu tiên là số ~n~ là số phần tử của mảng (~1\le n\le10^5~)
  • Dòng 2 là ~n~ số nguyên là các phần tử của mảng ~a~ (~|a_i|\le10^9~)
  • Dòng 3 là 1 số ~q~ là số truy vấn(~1\le q \le10^5~)
  • ~q~ dòng sau, mỗi dòng là một truy vấn thuộc một trong hai loại trên.

Output

Với mỗi truy vấn loại 2, in ra câu trả lời trên một dòng

Sample Input

3
1 2 3
7
1 1 3 1
1 2 3 4
2 1 3
1 1 1 5
2 1 2
1 1 2 2
2 2 3

Sample Output

8
7
9

Comments

Please read the guidelines before commenting.



  • 0
    ngd4491  commented on Jan. 5, 2026, 4:25 p.m.

    đa tạ người chủ contest công đức vô lượng


  • -38
    tranbaphu098  commented on April 24, 2025, 12:21 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -43
    tranbaphu098  commented on April 24, 2025, 12:20 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -54
    tranbaphu098  commented on April 24, 2025, 12:19 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • 3
    tiendungnguyen860  commented on Jan. 27, 2025, 8:49 a.m.

    mng comment nghiêm túc đi ạ!!!


  • 14
    Neymar21_Junior04  commented on Oct. 17, 2024, 3:26 p.m.

    Mng comment nghiêm túc nhaa!!


  • -28
    sunshine262  commented on July 11, 2024, 7:53 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -27
    melondepchai  commented on May 31, 2024, 12:32 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -23
    nguyenminhquanzp01  commented on March 23, 2024, 3:08 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -26
    GildurBeachParty  commented on Feb. 3, 2024, 6:22 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -30
    playerno1  commented on Dec. 28, 2023, 7:29 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -25
    Helectric  commented on Dec. 16, 2023, 4:02 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -38
    HoaBanMaTuy  commented on Oct. 13, 2023, 9:03 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -108
    reddevils2709  commented on Feb. 14, 2023, 2:01 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.