#C11482. Maximum Resource Path Sum in Kingdoms

    ID: 40803 Type: Default 1000ms 256MiB

Maximum Resource Path Sum in Kingdoms

Maximum Resource Path Sum in Kingdoms

You are given two kingdoms, each with a series of mines. The first kingdom has n mines and the second kingdom has m mines. Each mine produces a certain amount of resource. The resources are given in two arrays a and b respectively.

You will be given q queries. There are three types of queries:

  • Type 1: 1 idx x — update the resource of the idx-th mine in the first kingdom to x.
  • Type 2: 2 idx x — update the resource of the idx-th mine in the second kingdom to x.
  • Type 3: 3 — compute the maximum resource path sum for each kingdom. Here, the maximum resource path sum is defined as the total sum of resources of all mines in that kingdom, i.e. \(\sum_{i=1}^{n} a_i\) for the first kingdom and \(\sum_{j=1}^{m} b_j\) for the second kingdom.

Process the queries in the given order and output the result for every query of type 3.

inputFormat

The first line contains three integers n, m, and q — the number of mines in the first kingdom, the number of mines in the second kingdom, and the number of queries respectively.

The second line contains n integers representing the initial resources of the mines in the first kingdom.

The third line contains m integers representing the initial resources of the mines in the second kingdom.

The next q lines each contain a query. A query can be in one of the following formats:

  • 1 idx x
  • 2 idx x
  • 3

For queries of type 1 and 2, idx is a 1-indexed position and x is the new value.

outputFormat

For each query of type 3, output a single line containing two integers separated by a space. The first integer is the sum of the resources in the first kingdom and the second integer is the sum of the resources in the second kingdom.

## sample
4 3 3
5 6 3 4
8 4 2
3
1 2 10
3
18 14

22 14

</p>