codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1874A.md (2271B)


      1 Source: https://codeforces.com/problemset/problem/1874/A
      2 
      3 A. Jellyfish and Game
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Jellyfish has $n$ green apples with values $a_1, a_2, \dots, a_n$ and Gellyfish has $m$ green apples with values $b_1,b_2,\ldots,b_m$.
     22 
     23 They will play a game with $k$ rounds. For $i=1,2,\ldots,k$ in this order, they will perform the following actions:
     24 
     25 * If $i$ is odd, Jellyfish can choose to swap one of her apples with one of Gellyfish's apples or do nothing.
     26 * If $i$ is even, Gellyfish can choose to swap one of his apples with one of Jellyfish's apples or do nothing.
     27 
     28 Both players want to maximize the sum of the values of their apples.
     29 
     30 Since you are one of the smartest people in the world, Jellyfish wants you to tell her the final sum of the value of her apples after all $k$ rounds of the game. Assume that both Jellyfish and Gellyfish play optimally to maximize the sum of values of their apples.
     31 
     32 Input
     33 
     34 Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \leq t \leq 2000$). The description of the test cases follows.
     35 
     36 The first line of each test case contains three integers, $n$, $m$ and $k$ ($1 \leq n, m \leq 50$, $1 \leq k \leq 10^9$) — the number of green apples Jellyfish has, the number of green apples Gellyfish has and the number of rounds of the game respectively.
     37 
     38 The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \leq a_i \leq 10^9$) — the values of Jellyfish's green apples.
     39 
     40 The third line of each test case contains $m$ integers $b_1, b_2, \dots, b_m$ ($1 \leq b_i \leq 10^9$) — the values of Gellyfish's green apples.
     41 
     42 Do note that the sum of $n$ and $m$ over all test cases are both not bounded.
     43 
     44 Output
     45 
     46 For each test case, output a single integer — the final sum of the values of Jellyfish's apples.
     47 
     48 Example
     49 
     50 Input
     51 
     52 ```
     53 4
     54 
     55 2 2 1
     56 
     57 1 2
     58 
     59 3 4
     60 
     61 1 1 10000
     62 
     63 1
     64 
     65 2
     66 
     67 4 5 11037
     68 
     69 1 1 4 5
     70 
     71 1 9 1 9 8
     72 
     73 1 1 1
     74 
     75 2
     76 
     77 1
     78 ```
     79 
     80 Output
     81 
     82 ```
     83 6
     84 1
     85 19
     86 2
     87 ```
     88 
     89 Note
     90 
     91 In the first test case, Jellyfish will swap the apple of value $1$ and $4$.
     92 
     93 In the second test case, both players will swap the two apples $10,000$ times.
     94 
     95 In the fourth test case, Jellyfish will do nothing.