There is a deck of $$$n$$$ cards, each card has one of $$$k$$$ types. You are given the sequence $$$a_1, a_2, \dots, a_n$$$ denoting the types of cards in the deck from top to bottom. Both $$$n$$$ and $$$k$$$ are even numbers.
You play a game with these cards. First, you draw $$$k$$$ topmost cards from the deck. Then, the following happens each turn of the game:
You have to calculate the maximum number of coins you can earn during the game.
The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le k \le n \le 1000$$$, both $$$n$$$ and $$$k$$$ are even).
The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$).
Print one integer — the maximum number of coins you can earn.
4 21 2 1 2
0
8 22 1 2 2 1 2 1 2
1
4 41 2 1 2
2
6 43 2 3 1 2 1
3
6 43 2 3 3 2 1
2
18 65 6 1 1 6 5 4 1 5 1 1 6 2 6 2 2 6 3
6
8 41 2 3 4 4 3 1 2
2
8 41 2 3 4 4 3 3 2
3
Name |
---|