#P12013. [Ynoi April Fool's Round 2025] 牢夸

[Ynoi April Fool's Round 2025] 牢夸

Background

Problem Description

Ai Hoshino Aiku Aimi gives you a sequence a1,,ana_1,\dots,a_n of length nn, with a total of mm operations. There are two types of operations:

  1. Given l,r,xl,r,x, add xx to al,,ara_l,\dots,a_r.
  2. Given l,rl,r, query $\mathop{\max}\limits_{l\le L<R\le r}\frac{\sum\limits_{i=L}^R a_i}{R-L+1}$.

Input Format

The first line contains two integers n,mn,m.

The second line contains nn integers a1,,ana_1,\dots,a_n.

The next mm lines each contain either 1,l,r,x or 2,l,r, describing one operation.

Output Format

For each operation of type 2, output one line containing the answer as an irreducible fraction (in the form a/b or -a/b or 0/1; a,ba,b are coprime positive integers). For example, 53,  46,  1,  0,  2\frac{5}{3},\;-\frac46,\;-1,\;0,\;2 should be output as 5/3, -2/3, -1/1, 0/1, 2/1, respectively.

5 8
-7 -8 -1 5 8
1 4 5 -3
1 2 3 7
1 5 5 3
1 1 4 1
2 4 5
1 3 4 -1
1 1 2 7
2 4 5
11/2
5/1

Hint

Idea: nzhtl1477, Solution: ccz181078, Code: ccz181078, Data: ccz181078.

For 25%25\% of the testdata, n,m100n,m\le 100.

For 50%50\% of the testdata, n,m8000n,m\le 8000.

For the other 25%25\% of the testdata, there is no operation 1.

For 100%100\% of the testdata, 1n,m1061\le n,m\le 10^6, ai,x103|a_i|,|x|\le 10^3, and all values are integers. For operation 2, it is guaranteed that there is no case with l=rl=r.

Translated by ChatGPT 5