| UTPC Contest 10-1-25 Div. 2 (Beginner) |
|---|
| Закончено |
Cookie Sigma is ready to play some Clash Royale! Before he can battle for trophies, he must build his deck.
He is given two arrays of size $$$n$$$ $$$(4 \leq n \leq 100)$$$, $$$a$$$ and $$$b$$$. Each index $$$i$$$ $$$(1 \leq i \leq n)$$$ represents a pair of cards with elixir costs $$$a_i$$$ and $$$b_i$$$.
To build his deck, Cookie Sigma must follow these rules:
Cookie Sigma loves cycle decks and wants to minimize the total elixir cost of his deck. Help him determine the minimum possible total elixir cost of any valid deck he can create!
The first line contains an integer $$$n$$$ $$$(4 \leq n \leq 100)$$$, the size of $$$a$$$ and $$$b$$$.
The second line contains $$$n$$$ integers, $$$[a_1, a_2, ... a_n]$$$ $$$(1 \leq a_i \leq 1000$$$), the elements in $$$a$$$.
The third line contains $$$n$$$ integers, $$$[b_1, b_2, ... b_n]$$$ $$$(1 \leq b_i \leq 1000$$$), the elements in $$$b$$$.
Output one number, the minimum possible total elixir cost of a valid deck Cookie Sigma can create. Note that this is the total cost of his deck (the sum of elixir of all cards in his deck), NOT the average elixir cost.
64 3 9 2 9 21 3 8 3 1 5
23
In the example test case, it is optimal for Cookie Sigma to pick indices $$$1, 2, 4, 6$$$ and add the cards at these indices to his deck. By doing this, his deck will consist of cards with elixir costs $$$[1, 2, 2, 3, 3, 3, 4, 5]$$$. Summing these up, we can see that the total elixir cost of his deck is 23 elixir.
| Название |
|---|


