Bruteforce
Time limit5sMemory limit512 MB
After each point update to an array, report the sum over sorted values of floor(b_i * i^k / w), with k and w at most 5, modulo 998244353.
- Level
Medium6 of 10
- Topics
- Sorting, Brute force, Implementation, Math
- Solved
- No attempts yet
Problem
You are given fixed integers and .
For an array of length , its weight is defined as follows.
- Let be the array sorted in non-descending order.
- The weight of is .
Here, is the largest integer not exceeding .
For example, if and , then the weight of is
.
You are given an initial array , and then queries. Each query changes one element of array . After each query, output the new weight of the array. Array weights can be very large, so output them modulo .
Changes persist between queries. For example, the second query is applied to the array already changed by the first query.
Input
The first line contains three integers , , (, , ): the length of the array and the parameters from the statement.
The second line contains integers (): the elements of the original array.
The third line contains a single integer (): the number of queries.
Each of the next lines contains two integers and (, ). This describes a query that changes into .
Output
Output integers: the weight of the array after each change, modulo .