CF1570I.Minimum Difference

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer array aa of size nn .

You have to perform mm queries. Each query has one of two types:

  • " 11 ll rr kk " — calculate the minimum value difdif such that there are exist kk distinct integers x1,x2,,xkx_1, x_2, \dots, x_k such that cnti>0cnt_i > 0 (for every i[1,k]i \in [1, k] ) and cnticntjdif|cnt_i - cnt_j| \le dif (for every i[1,k],j[1,k]i \in [1, k], j \in [1, k] ), where cnticnt_i is the number of occurrences of xix_i in the subarray a[l..r]a[l..r] . If it is impossible to choose kk integers, report it;
  • " 22 pp xx " — assign ap:=xa_{p} := x .

输入格式

The first line contains two integers nn and mm ( 1n,m1051 \le n, m \le 10^5 ) — the size of the array aa and the number of queries.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai1051 \le a_i \le 10^5 ).

Next mm lines contain queries (one per line). Each query has one of two types:

  • " 11 ll rr kk " ( 1lrn;1k1051 \le l \le r \le n; 1 \le k \le 10^5 )
  • " 22 pp xx " ( 1pn;1x1051 \le p \le n; 1 \le x \le 10^5 ).

It's guaranteed that there is at least one query of the first type.

输出格式

For each query of the first type, print the minimum value of difdif that satisfies all required conditions, or 1-1 if it is impossible to choose kk distinct integers.

输入输出样例

  • 输入#1

    12 11
    2 1 1 2 1 1 3 2 1 1 3 3
    1 2 10 3
    1 2 11 3
    2 7 2
    1 3 9 2
    1 1 12 1
    1 1 12 4
    2 12 4
    1 1 12 4
    2 1 5
    1 3 12 2
    1 1 4 3

    输出#1

    5
    4
    1
    0
    -1
    5
    0
    1
首页