#P15681. 分糖果

    ID: 17745 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>线段树二分树状数组

分糖果

Problem Description

You are given a sequence a1,a2,…,ana_1,a_2,\dots,a_n of length nn and qq operations. There are two types of operations in total:

  1. Given x,yx,y, you need to modify the value of axa_x to yy.
  2. Given m,km,k, you need to compute the following: suppose there are currently mm baskets and nn people. The ii-th person will choose aia_i distinct baskets and put 11 candy into each of these aia_i baskets. Find the maximum possible number of baskets that end up with exactly kk candies.

Input Format

The first line contains three integers c,n,qc,n,q, where cc denotes the test point ID. The samples satisfy c=0c=0.

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

The next qq lines each contain three integers, in the form 1 x y1\ x\ y or 2 m k2\ m\ k, representing the first type of operation and the second type of operation, respectively.

Output Format

For each operation of the second type, output one line containing one integer, which is the answer.

0 3 4
1 2 5
2 5 2
1 3 3
2 4 1
2 5 0
3
3
2

Hint

Explanation for Sample 1

  • For the first operation, a={1,2,5}a=\{1,2,5\}, m=5m=5, k=2k=2. Person 11 can choose to put 11 candy into basket 11. Person 22 can choose to put 11 candy into basket 22 and basket 33. Person 33 can only choose to put 11 candy into all baskets. Then baskets 1,2,31,2,3 each have exactly 22 candies. It is easy to prove that this maximizes the number of baskets with exactly 22 candies.
  • For the third operation, a={1,2,3}a=\{1,2,3\}, m=4m=4, k=1k=1. Person 11 can choose to put 11 candy into basket 11. Person 22 can choose to put 11 candy into basket 11 and basket 22. Person 33 can choose to put 11 candy into baskets 1,3,41,3,4. Then baskets 2,3,42,3,4 each have exactly 11 candy. It is easy to prove that this maximizes the number of baskets with exactly 11 candy.
  • For the fourth operation, a={1,2,3}a=\{1,2,3\}, m=5m=5, k=0k=0. Person 11 can choose to put 11 candy into basket 11. Person 22 can choose to put 11 candy into basket 11 and basket 22. Person 33 can choose to put 11 candy into baskets 1,2,31,2,3. Then basket 44 and basket 55 each have exactly 11 candy. It is easy to prove that this maximizes the number of baskets with exactly 00 candies.

Sample 2

See candy/candy2.in and candy/candy2.ans.

This sample set satisfies the constraints of test point 44.

Sample 3

See candy/candy3.in and candy/candy3.ans.

This sample set satisfies the constraints of test point 99.

Sample 4

See candy/candy4.in and candy/candy4.ans.

This sample set satisfies the constraints of test point 1010.

Sample 5

See candy/candy5.in and candy/candy5.ans.

This sample set satisfies the constraints of test point 1515.

Sample 6

See candy/candy6.in and candy/candy6.ans.

This sample set satisfies the constraints of test point 1717.

Sample 7

See candy/candy7.in and candy/candy7.ans.

This sample set satisfies the constraints of test point 1818.

Sample 8

See candy/candy8.in and candy/candy8.ans.

This sample set satisfies the constraints of test point 2020.

Constraints

For all testdata, it is guaranteed that:

  • 1≤n,q≤5×1051 \le n,q \le 5\times10^5.
  • 1≤ai≤1061 \le a_i \le 10^6.
  • 1≤x≤n1 \le x \le n, 1≤y≤1061 \le y \le 10^6.
  • max⁡ai≤m≤1012\max a_i \le m \le 10^{12}, 0≤k≤n0 \le k \le n.

::cute-table{tuack}

Test point ID n,q≤n,q\le Special property
11 55 A
22 B
33 400400 BC
4∼54\sim5 None
66 50005000 BC
77 B
88 C
99 None
1010 10510^5 BC
1111 B
1212 C
13∼1413\sim14 None
1515 5×1055\times10^5 A
1616 BC
1717 B
1818 C
19∼2019\sim20 None
  • Special property A: it is guaranteed that m≤7m \le 7.
  • Special property B: it is guaranteed that m=1012m=10^{12}.
  • Special property C: it is guaranteed that there is no operation of the first type.

Translated by ChatGPT 5