(There won’t be extra line breakers
in the actual test cases.)
In the first sample, you can successively perform the following operations:
Assign at a cost of , then ;
Assign at a cost of , then ;
Assign at a cost of , then ;
Assign at a cost of , then .
After the operations, only the color of element is , so your score is equal to . It can be shown that it is impossible to obtain a score greater than .