CF862E Mahmoud and Ehab and the function
Description
Dr. Evil is interested in math and functions, so he gave Mahmoud and Ehab array $ a $ of length $ n $ and array $ b $ of length $ m $ . He introduced a function $ f(j) $ which is defined for integers $ j $ , which satisfy $ 0
Input Format
The first line contains three integers $ n,m $ and $ q $ ( $ 1
Output Format
The first line should contain the minimum value of the function $ f $ before any update.
Then output $ q $ lines, the $ i $ -th of them should contain the minimum value of the function $ f $ after performing the $ i $ -th update .
Explanation/Hint
For the first example before any updates it's optimal to choose $ j=0 $ , $ f(0)=|(1-1)-(2-2)+(3-3)-(4-4)+(5-5)|=|0|=0 $ .
After the first update $ a $ becomes $ {11,2,3,4,5} $ and it's optimal to choose $ j=1 $ , $ f(1)=|(11-2)-(2-3)+(3-4)-(4-5)+(5-6)=|9|=9 $ .
After the second update $ a $ becomes $ {2,2,3,4,5} $ and it's optimal to choose $ j=1 $ , $ f(1)=|(2-2)-(2-3)+(3-4)-(4-5)+(5-6)|=|0|=0 $ .
After the third update $ a $ becomes $ {1,1,2,3,4} $ and it's optimal to choose $ j=0 $ , $ f(0)=|(1-1)-(1-2)+(2-3)-(3-4)+(4-5)|=|0|=0 $ .